Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: converting date to milliseconds?
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 toolReceived on Thu Mar 31 2005 - 15:40:51 CST