3

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?

muttley91
  • 12,278
  • 33
  • 106
  • 160
  • You have tagged your question with `Sql-server` tag and you are using Mysql function `DATE_SUB` in your where clause ??? are you working on Mysql or Sql-server ??? – M.Ali Feb 05 '14 at 19:28

1 Answers1

9

Sql-Server

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

Mysql

WHERE DateTimeColumn > DATE_SUB(NOW(), INTERVAL 48 HOUR)
M.Ali
  • 67,945
  • 13
  • 101
  • 127