Get Data From Last 48 Hours

被刻印的时光 ゝ 提交于 2019-12-11 12:09:44

问题


I'm using PowerPivot with an SQL Server database and I'm working with a specific table that includes a DateTime column. I'd like to select the data from the table where that DateTime is within the last 48 hours. I'm using a query currently and hoping to achieve something like

... WHERE DT > DATE_SUB(CURRENT_TIMESTAMP, INTERVAL +2 DAY)

I'm getting a syntax error at DAY in this particular way. Is this the best way to do it? If so, what's wrong with how I've written it? If not, what's a better way?


回答1:


Sql-Server

WHERE DateTimeColumn >= DATEADD(HOUR, -48, GETDATE())

Mysql

WHERE DateTimeColumn > DATE_SUB(NOW(), INTERVAL 48 HOUR)


来源:https://stackoverflow.com/questions/21586548/get-data-from-last-48-hours

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!