获取过去24小时的记录

时间:2014-07-25 19:59:30

标签: sql sql-server timestamp

我有一个显示时间戳的SQL查询。我如何获得过去24小时的记录。我们正在使用MS SQL Server 2012,但以下查询

select DATEADD(SECOND, TIME_STAMP /1000 + 8*60*60, '19700101') 
as Date_and_Time from [dbo].[V_AGENT_SYSTEM_LOG] 
where EVENT_SOURCE = 'sylink'and EVENT_DESC like '%Downloaded%'
and TIME_STAMP >= SYSDATE() - 1

返回错误

Msg 195, Level 15, State 10, Line 4
'SYSDATE' is not a recognized built-in function name.

谢谢

1 个答案:

答案 0 :(得分:1)

Sysdate是Oracle - 使用Getdate()

select DATEADD(SECOND, TIME_STAMP /1000 + 8*60*60, '19700101') 
as Date_and_Time from [dbo].[V_AGENT_SYSTEM_LOG] 
where EVENT_SOURCE = 'sylink'and EVENT_DESC like '%Downloaded%'
and TIME_STAMP >= GETDATE() - 1