获取过去48小时的数据

编程入门 行业动态 更新时间:2024-10-28 04:25:23
本文介绍了获取过去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小时的数据

本文发布于:2023-11-27 02:03:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636117.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:小时   数据

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!