Solved

ORACLE date conversion

Posted on 2002-07-16
3
2,903 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
Comment Utility
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
Comment Utility
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
Comment Utility
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.

Join & Write a Comment

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 …
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to recover a database from a user managed backup

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now