Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Date decoding question

Author  Topic 

FGlock
Starting Member

3 Posts

Posted - 2005-09-26 : 13:29:15
The dates in the SQL database look like this:

open_date
1095768487
1095703930
1126727859

I would like to know how to convert the date into something usable. For instance, the 3rd value is really 9/14/2005. I'm using Query Analyzer.

Thanks for any guidance you might provide.



SamC
White Water Yakist

3467 Posts

Posted - 2005-09-26 : 14:37:38
What is the data type of open_date ? DATETIME, VARCHAR, INT ?
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-09-26 : 14:54:21
Hi FGlock, Welcome to SQL Team!

Are these Unix "seconds since 01-Jan-1970"?

if so I would do:

select dateadd(second, open_date, '19700101')

Kristen
Go to Top of Page

FGlock
Starting Member

3 Posts

Posted - 2005-09-26 : 15:17:30
quote:
Originally posted by Kristen

Hi FGlock, Welcome to SQL Team!

Are these Unix "seconds since 01-Jan-1970"?

if so I would do:

select dateadd(second, open_date, '19700101')

Kristen

Go to Top of Page

FGlock
Starting Member

3 Posts

Posted - 2005-09-26 : 15:21:09
Kristen - I want to thank you so much. The code sample you sent me worked beautifully. I have been struggling with this for many hours trying to glean what I could from others' postings, but nothing I tried seemed to work. I am a mainframe person (used to JCL and batch jobs) so this is a new world for me doing online queries in the server world. Thanks again and have a great day!

By the way, the date shows as Int, Null in the listing in Query Analyzer.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-27 : 01:04:49
>>Are these Unix "seconds since 01-Jan-1970"?

Kris, how did you find that?
Is 01-Jan-1970 mimimum date in Unix?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-09-27 : 03:12:12
We "pull" some data from an Oracle application which seems to favour storing dates as "seconds since 01-Jan-1970".

The numbers looked about the right size!

Kristen
Go to Top of Page
   

- Advertisement -