July 31, 2003 at 10:54 am
I've been following the discussion on using DATEADD instead of CONVERT when doing queries on just the Date portion of the datetime datatype.
However, the code being discussed just uses DATEADD to end up with the date followed by 00:00:00
What is the best way to use datetime datatype in a WHERE statement when you need a specific time?
Currently I use this:
WHERE mydate >= CONVERT(VARCHAR(10), GETDATE(), 120) + ' 05:00:00'
Which is the same as:
WHERE mydate >= '2003-07-31 05:00:00'
Is there a better way to do that instead of converting to a varchar?
-SQLBill
July 31, 2003 at 11:16 am
Lots of ways to strip the time. Here is how I would do
DATEADD(hh,5,DATEADD(d,DATEDIFF(d,0,GETDATE()),0))
July 31, 2003 at 11:30 am
Did exactly what I wanted.
Thanks.
-SQLBill
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply