Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert long int to date 1

Status
Not open for further replies.

wgechter

MIS
Jul 24, 2002
85
US
I have a field d_chart_open, type number(11) that has values such as 55666, 55687, etc. I would like those numbers to be displayed as a date, May 29, 02 or 5/29/02 but am not sure the formula I should use. All dates are based off the date 12/31/1849. I am using Oracle SQL Plus. Thanks, Wendi
 
I tried this answer but didn't work, what I've found is that in my case the type is long(4). What modifications shall be done? Values are like : 1114582520
 
I doubt the numbers like that denote days passed from some base date. Most likely they mean seconds. So devide your numbers by number of seconds in 24 hours (24*60*60) and add to your base date.
 
The base date should be in the DB description. It can be 01-JAN-1900, 01-JAN-1950, or anythin else. To make calculations, just use
...to_date('01-JAN-1900')+ your_long4_field/86400
 
Thanks, the answer is:

SELECT to_date('1-JAN-1970')+F_SGTM/(24*60*60) FROM SGRP_EXT

Figured it out just a couple of mins before I got your email but thanks anyways!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top