Tuesday, August 20, 2013

sybase sql how to get a timestamp for a past date

This assumes your using the 'datetime' type in sql. The important part is where you use the dateadd funtion

This is for a timestamp two weeks ago.

select name, executiontime
from tasktable
where executiontime < dateadd(week,-2,getdate())
go

Of course you can play around with the dateadd parameters to get timestamps for whatever time you want.

No comments:

Post a Comment