I can get the whole of yesterday and today using this query
Casting GETDATE to INT truncates the time element and casting back to DATETIME resets the time element to midnight.
I figured if I did something like this it would give me 17:00 yesterday
But error:
I must be close.
Any help appreciated
Code:
SELECT site, ord_date, LEFT(RTRIM(LTRIM(descr)),24) account FROM orders WHERE ord_date BETWEEN CAST(CAST(DATEADD(DAY,-1,GETDATE()) AS INT) AS DATETIME) AND CAST(GETDATE() AS DATETIME)
I figured if I did something like this it would give me 17:00 yesterday
Code:
CAST(CAST(DATEADD(DAY,-1,GETDATE()) AS INT)+' 17:00:00.000' AS DATETIME)
Syntax error converting the varchar value ' 17:00:00.000' to a column of data type int.
Any help appreciated
Comment