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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to convert a Greenwich Mean Time to an ordinary date/time in sql? 1

Status
Not open for further replies.

cyan01

Programmer
Mar 13, 2002
143
US
Hi, Experts,

I have an Oracle table which has a field whose datetype is NUMBER. The values in this field are the outputs of a perl library function "time", i.e. the number of non-leap seconds since 01/01/1970, UTC (Greenwich Mean Time). What is the sql syntax to convert this value into an ordinary date/time format?

Thanks!
 
If I understand your requirements correctly, you need something like this

Code:
SELECT To_Date('01/01/1970','DD/MM/YYYY') + (<your number>/86400)
FROM sys.dual;

This is the number of days since 01/01/1970 added to 01/01/1970 to give you the current date. The number of days is calculated as your number divided by the number of seconds in a day.

The result will give you the date in UTC, so you will need to adjust for your timezone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top