Converting seconds into dates in a SELECT
Posted in 1999
Topics: SQL Development & Query Writing, Stored Procedures & SPL, Jobs, Consulting & Announcements
Would anyone know of a way I can display a "date" value that has been stored in seconds since 1/1/1970 in a formated date format? I have a column that stores a date in seconds. I'd like to write a select statement that creates a displayed column that converts that data into a date. Thanks, Dan -- Daniel Kirkdorffer Sr. Consultant, Syllogistics, LLC. Email: dan.kirkdorffer 'at' syllogistics 'dot' com daniel.kirkdorffer 'at' attws 'dot' com Web: http://www.syllogistics.com/ http://members.aol.com/dankirkd/ Visual Cafe Tips: http://members.aol.com/dankirkd/vcafe.htm
Daniel Kirkdorffer wrote: > Would anyone know of a way I can display a "date" value that has been > stored in seconds since 1/1/1970 in a formated date format? Give or take problems with time zones: DATE(DATETIME(1970-01-01 00:00:00) YEAR TO SECOND + val_in_sec UNITS SECOND) This is getting to the point of being a FAQ -- I've lost track of how many times I've given minor variants of this answer. The primary variation this time was wrapping DATE(...) around the DATETIME expression. > I have a column that stores a date in seconds. I'd like to write a > select statement that creates a displayed column that converts that > data into a date. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN #include <disclaimer.h>
In article <36A1121E.2283@earthlink.net>, Jonathan Leffler <jleffler@earthlink.net> writes >Daniel Kirkdorffer wrote: >> Would anyone know of a way I can display a "date" value that has been >> stored in seconds since 1/1/1970 in a formated date format? > >Give or take problems with time zones: > >DATE(DATETIME(1970-01-01 00:00:00) YEAR TO SECOND + > val_in_sec UNITS SECOND) > >This is getting to the point of being a FAQ -- I've lost track of how >many times I've given minor variants of this answer. The primary >variation this time was wrapping DATE(...) around the DATETIME >expression. > I'll add it now... >> I have a column that stores a date in seconds. I'd like to write a >> select statement that creates a displayed column that converts that >> data into a date. > -- David Williams