Solved

Converting integer based (UNIX?) time to and from sql

Posted on 2009-05-18
1
208 Views
Last Modified: 2012-08-14
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?

Thanks
0
Comment
Question by:advlgx
1 Comment
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 24416933
DATEDIFF(s, '19700101', GETDATE())
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now