Home » SQL & PL/SQL » SQL & PL/SQL » Converting datetime to number and viceversa
Converting datetime to number and viceversa [message #11926] Thu, 22 April 2004 07:32 Go to next message
Naresh
Messages: 27
Registered: March 2001
Junior Member
 

To avoid formatting the date values in a particular format and then parsing it, I would like to convert date time to a number for my application.

The build-in conversion function does not support this.

Thanks,

Naresh

 

 
Re: Converting datetime to number and viceversa [message #11930 is a reply to message #11926] Thu, 22 April 2004 10:52 Go to previous message
sverch
Messages: 582
Registered: December 2000
Senior Member
just date:

SQL> select to_char(sysdate,'ddmmyyyyhhmiss') from dual;

TO_CHAR(SYSDAT
--------------
22042004023944

date and time:

SQL> select to_char(sysdate,'ddmmyyyyhhmiss') from dual;

TO_CHAR(SYSDAT
--------------
22042004024100

You can TO_NUMBER these selects:

SQL> set numformat 99999999999999
SQL> select to_number(to_char(sysdate,'ddmmyyyyhhmiss'), 99999999999999) from dual;

TO_NUMBER(TO_CHAR(SYSDATE,'DDMMYYYYHHMISS'),99999999999999)
-----------------------------------------------------------
22042004025706
Previous Topic: In a quandry
Next Topic: Loop with a Counter
Goto Forum:
  


Current Time: Wed Jul 23 11:40:47 CDT 2025