Getting t-1

  • 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

  • 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

  • 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)

  • 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