开发者

How can I get reports for last 24h in SQL?

I need to get all reports made in last 24h, 开发者_Python百科table has CreatedDate column, so I need to check in database that report was created in last 24h. I know I can use getdate() to get current date, but how can I minus 24h from that attrbiute and then compare that date with CretedDate?


You can use the DATEADD() function as follows:

... WHERE CreatedDate > DATEADD(HOUR, -24, GETDATE())


myDateTimeColumn BETWEEN GetDate() - 1 AND GetDate()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜