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 a number to a date or timestamp 1

Status
Not open for further replies.

jaxtell

Programmer
Sep 11, 2007
349
US
Hi,
One of the applications I'm using stores timestamps as numbers. IE 001206640065185 . Divide it by 100 and thats the number of seconds since Epoch. What is the easiest way to convert this to a Date datatype? Thanks.



-----------------------------------------
I cannot be bought. Find leasing information at
 
So that we can check our math, what is the date that represents the beginning of this particular Epoch?

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
Jan 1, 1970. The number previously posted should be Mar-27-2008 01:47:45 PM

-----------------------------------------
I cannot be bought. Find leasing information at
 
This is what is looks like in php

Code:
cat date.php
<?php
$ts = 1206640065185 / 1000;

echo date('M-d-Y h:i',$ts);
?>
[axtell@server1 ~]$ php date.php
X-Powered-By: PHP/4.4.6
Content-type: text/html

Mar-27-2008 12:47

Hmm, I'll have to check my java code to find out why the hours are 1 off.

-----------------------------------------
I cannot be bought. Find leasing information at
 
You can perform this conversion in Oracle with

Code:
to_date('01-JAN-1970', 'dd-mon-yyyy') + 001206640065185/1000/3600/24

as you can verify with the following select statement

Code:
select to_char(to_date('01-JAN-1970', 'dd-mon-yyyy') + 001206640065185/1000/3600/24, 'dd-mon-yyyy.hh24:mi:ss') from dual

27-mar-2008.17:47:45
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top