Glowie
Glowie

Reputation: 2309

Get records for past 24 hours

I have an SQL query that displays timestamp. How do I get records for past 24 hours. We are using MS SQL Server 2012, but the following query

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

returns error

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

Thank you

Upvotes: 0

Views: 317

Answers (1)

Dave.Gugg
Dave.Gugg

Reputation: 6771

Sysdate is Oracle - use 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

Upvotes: 1

Related Questions