Reputation: 281
I had this MySQL code
DELETE FROM UserError WHERE UNIX_TIMESTAMP() - UNIX_TIMESTAMP(date) > 86400
What is equivalent of this MySQL code in SQL Server?
Upvotes: 25
Views: 47168
Reputation: 13425
You can use datediff
DELETE FROM UserError WHERE
Datediff(s, [date], getdate()) > 86400
Upvotes: 48
Reputation: 7626
Try this:
SELECT DATEDIFF(second, '2005-12-31 23:59:59.9999999', '2006-01-01 00:00:00.0000000');
--Syntax
DATEDIFF ( datepart , startdate , enddate )
Upvotes: 5
Reputation: 5600
You can make use of DateDiff for this. It looks like this:
DateDiff(datePart,startDate,endDate)
Upvotes: 3