Converting integer based (UNIX?) time to and from sql
Posted on 2009-05-18
Basically, I am reading a time value in a database that is being stored in an int data type.
For example 1139678068 is a value in a field called TS_TIME that I have figured out how to convert to '2006-02-11 17:14:28.000' using the formula
DATEADD(s, TS_TIME, '19700101')
Now, I want to write back to the database. How would I convert getdate() into this integer type of time data using the inverse of the DATEADD function above?