Solved

ORACLE date conversion

Posted on 2002-07-16
3
2,912 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to recover a database from a user managed backup
Suggested Courses

631 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