November 25, 2015 at 3:09 am
I tried to schedule to get t-1 day data.
Schedule time at 4am (gmt +8).
But the data only appear from 00:00 till 20:00.
How can I get t-1 from 00:00 till 23:59:59?
Currently I apply getdate()-1
November 25, 2015 at 3:13 am
Try this code
select convert(datetime,convert(date,getdate()-1)),DATEADD(millisecond,-3,convert(datetime,DATEADD(day,1,convert(date,getdate()-1))))
Igor Micev,My blog: www.igormicev.com
November 25, 2015 at 3:07 pm
Often people use a dateadd/datediff combination to remove times, or to set to a base time.
SELECT DateAdd(Day, Datediff(Day,0, GetDate() -1), 0)
returns midnight of yesterday. That might be what you want. The -1 goes to yesterday. If I remove that, I get today.
SELECT DateAdd(Day, Datediff(Day,0, GetDate() ), 0)
November 25, 2015 at 7:18 pm
I tried still the same. It only will pull from 00:00 till 19:59.
As my end I schedule it at 4am (gmt+8).
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply