Skip to content
Advertisement

Getdate(), -1 day

I do not understand why, but somehow this query doesn’t work. I want to take system date -1 day where the sysdate is smaller by 1 day then current date.

WHERE
    a.SEND_Date >= dateadd(DD,-1,(CAST(getdate() as date) as datetime)) 

Advertisement

Answer

The CAST depends on what kind of date type you need. If you need only to compare dates you can use only:

dateadd(DD, -1, cast(getdate() as date))

If you need to compare with date time you can use:

dateadd(DD,-1,getdate())

That wil give you datetime like this: 2016-01-11 10:43:57.443

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement