获取过去48小时的数据 [英] Get Data From Last 48 Hours

查看:327
本文介绍了获取过去48小时的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将PowerPivot与SQL Server数据库一起使用,并且正在处理包含DateTime列的特定表。我想从过去48小时内DateTime所在的表中选择数据。我目前正在使用查询,希望能实现类似

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,间隔+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?

推荐答案

Sql-Server

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

Mysql

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

这篇关于获取过去48小时的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆