Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select query Based On Date And Time

Status
Not open for further replies.

hcclSmokey

Technical User
May 9, 2003
23
0
0
GB
Hi There

I am trying to find out how to write a select query based on the current date and current time. The query needs to return a result from a column, phone number, in my table based on the current date and time. My record is quite simple;

Date Time Phone Number
24/06/2004 12:00:00 555-1234

Any help would be greatly appreciated.

Regards
Smokey
 
I'm only showing the pertinant part of the code, but try this:

Code:
WHERE [Date] = CONVERT(CHAR(10), GETDATE(), 103)
  AND [Time] = SUBSTRING(CONVERT(CHAR(20), GETDATE(), 120), 12, 8)

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top