我有一个显示时间戳的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.
谢谢
答案 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