I have a table which contain a column named timestamp
which stores created datetime of the record in seconds(convert the datetime value from Date() using strtotime()). I need to get the records whose created date is greater than 72 hours in order to delete those records.
My table has following columns:
userid(int)
timestamp(storing created dates in seconds)eg:'1427886372'
I have used the following query
SELECT DATEDIFF(HOUR,timestamp,'current date in seconds')>72 FROM table_name.
Its not working. I would also like to know, if there is any option to convert the result of GETDATE()
to seconds in sql just like strtotime()
in php since I am getting the current date using php Date()
and converting it to seconds using strtotime()
.
**EDIT:**According to kba's answer I have modified the query like this.
SELECT * FROM PRTL_UsrHashKeys where
DATEDIFF(HOUR,timestamp, DATEDIFF(second, '1970-01-01', GETDATE()))>72
But its showing An expression of non-boolean type specified in a context where a condition is expected, near ')'.