Home » SQL & PL/SQL » SQL & PL/SQL » Date conversion
Date conversion [message #645926] Wed, 16 December 2015 08:14 Go to next message
blyzz
Messages: 10
Registered: October 2015
Junior Member
I need to convert the value of number of days since 12/31/1840 as "date format" for a given date in Oracle
EX: FOR 2/28/15 I am getting value as 65400 and I want to display as 2/28/25

The function in crystal report is
Dateadd('d',tonumber(value),Date(1840,12,31))

But not sure how to do that in Oracle using dateadd function.


Thank you,
Blyzz
Re: Date conversion [message #645930 is a reply to message #645926] Wed, 16 December 2015 08:22 Go to previous messageGo to next message
Michel Cadot
Messages: 68763
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

Quote:
the value of number of days since 12/31/1840


This is not a number of days, this is a string representing a date.

Quote:
I am getting value as 65400 and I want to display as 2/28/25


Just add the number of days represented by your value to the base date (the one with value 0).

Re: Date conversion [message #645943 is a reply to message #645926] Wed, 16 December 2015 10:00 Go to previous message
Solomon Yakobson
Messages: 3305
Registered: January 2010
Location: Connecticut, USA
Senior Member
Oracle dates support date arithmetic using day as unit of measure:

SQL> select date '1840-12-31' + 65400 from dual;

DATE'1840
---------
22-JAN-20

SQL>


So, as you can see, 65400 days since December 31, 1840 isn't 2/28/15.

SY.
Previous Topic: PL SQL Code with variable
Next Topic: Date Conersion From UTC to EST
Goto Forum:
  


Current Time: Wed Jul 30 02:56:54 CDT 2025