Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: converting date to milliseconds?

Re: converting date to milliseconds?

From: Andy Hassall <andy_at_andyh.co.uk>
Date: Thu, 31 Mar 2005 22:40:51 +0100
Message-ID: <n0ro415if0k15gbdg7m68uh4ldpc1jb98i@4ax.com>


On 31 Mar 2005 13:11:06 -0800, laredotornado_at_zipmail.com wrote:

>Hello, I'm using Oracle 8.1.7 on Solaris. How would I write a select
>statement to convert a table column of the DATE type to something
>that's a NUMBER, preferrably with units of seconds or milliseconds?

 Seconds since when? If you addition or subtraction between DATE datatypes it converts it to a NUMBER indicating number of days, down to second resolution.

 e.g. to get the standard Unix-style seconds-since-epoch timestamp:

SQL> select (sysdate-to_date('19700101','YYYYMMDD'))*86400 from dual;

(SYSDATE-TO_DATE('19700101','YYYYMMDD'))*86400


                                    1112308598

 Millisecond accuracy only comes in at 9i with the TIMESTAMP datatype.

-- 
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Received on Thu Mar 31 2005 - 15:40:51 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US