June 23, 2015 at 7:17 pm
Hi SQL experts - What is the proper way to ensure when pulling date between two getdates, that you include from midnight of the first getdate to 23:59 hours in the second getdate?
WD.WRKD_WORK_DATE
and WD.WRKD_WORK_DATE between DATEADD(DD, - 11, GETDATE())
and DATEADD(DD, - 5, GETDATE())
Sandy Tucker
June 23, 2015 at 7:57 pm
SandyTucker (6/23/2015)
Hi SQL experts - What is the proper way to ensure when pulling date between two getdates, that you include from midnight of the first getdate to 23:59 hours in the second getdate?
This is one way:
WHERE (WD.WRKD_WORK_DATE >= cast(DATEADD(DD, - 11, GETDATE()) as date)
and WD.WRKD_WORK_DATE < cast(DATEADD(DD, -4, GETDATE()) as date))
__________________________________________________________________________________________________________
How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/
June 24, 2015 at 4:13 pm
Hello LinksUp - thanks very much, that seems to be working well!
Sandy Tucker
June 24, 2015 at 10:04 pm
Glad it worked for you!
__________________________________________________________________________________________________________
How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply