Solved

ORACLE date conversion

Posted on 2002-07-16
3
2,907 Views
Last Modified: 2006-11-17
I have an oracle 9i database.

I have a date stored in decimal format (seconds from epoch).  I am trying to convert it to a date I can compare to (month, day, year, hour, min, sec)using SQL syntax.

Sample syntax would be greatly appreciated.

Thank you.
0
Comment
Question by:WW2
3 Comments
 
LVL 1

Accepted Solution

by:
Bashar earned 50 total points
ID: 7158383
Hi,
I don't know what "epoch" means, but I can help you with some example.

suppose the starting date is 1/1/2002 00:00:00.
You want to convert the following number (which represents seconds from the starting date): 3209475.
You need to convert it to days by using this arithmetic:
(3209475/60/60/24), then you can add the resulting number to the date we have (1/1/2002 00:00:00) by issuing the following SQL statement:
select to_date('1/1/2002 00:00:00', 'dd/mm/yyyy hh24:mi:ss') + (3209475 / 60 / 60 / 24)
from dual

this will give you the new date that represents the number of seconds from the starting date.

I hope this is what you're looking for.

Regards,
Bashar.
0
 
LVL 2

Expert Comment

by:rajeXsh
ID: 7159407
Cant take credit for this link

http://www.orafaq.com/msgboard/unix/messages/438.htm

It just reiterates what Bashar has posted

-- rajeXsh

0
 
LVL 3

Expert Comment

by:patelgokul
ID: 9392263
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
accept bashar's comment as an answer
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

patelgokul
EE Cleanup Volunteer
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question