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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL date format query

Status
Not open for further replies.

panini

MIS
Jun 1, 2001
136
GB
I have a query that gets values from todays date or yesterdays date using:

(orderdate = CONVERT(CHAR(8), GETDATE(), 112))

and

(orderdate = CONVERT(CHAR(8), GETDATE()-1, 112))


The cell format used to be 25/12/2006 but it's now been changed to include a timestamp so it's

25/12/2006 10:15:00

Can anyone advice how I change the query to work with the new field?

Many thanks,
 
got it guys

(orderdate >= DATEADD([day], - 1, CONVERT(DATETIME, CONVERT(CHAR(8), GETDATE(), 112), 112)))

orderdate >= CONVERT(DATETIME, CONVERT(CHAR(8), GETDATE(), 112), 112)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top