add two dates [message #259062] |
Tue, 14 August 2007 05:53 |
guru_karnam
Messages: 142 Registered: May 2005
|
Senior Member |
|
|
How should i add two dates??
SELECT TO_DATE(TO_CHAR(SYSDATE,'YY-MM-DD HH24:MI:SS'),'YY-MM-DD HH24:MI:SS') +TO_DATE('01-05-01 04:12:27','YY-MM-DD HH24:MI:SS') FROM DUAL
This query gives an error. I want to add two dates and display the result
|
|
|
|
Re: add two dates [message #259084 is a reply to message #259062] |
Tue, 14 August 2007 06:30 |
pablolee
Messages: 2882 Registered: May 2007 Location: Scotland
|
Senior Member |
|
|
In addition to Michel's post:
No formatting
No version
You mention that you get an error but don't post what that error is.
|
|
|
|
Re: add two dates [message #259113 is a reply to message #259070] |
Tue, 14 August 2007 07:44 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
I'm with Michael on this one - I don't believe that 23rd June 1847 + 15th December 1998 has any meaning at all.
You can add a period of time onto a date - in Oracle you do that by adding a (potentially fractional) number of days onto a date, egbut adding dates to other dates is not possible.
|
|
|
Re: add two dates [message #259145 is a reply to message #259113] |
Tue, 14 August 2007 09:14 |
|
Michel Cadot
Messages: 68718 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Or you can use the well named INTERVAL datatype:
SQL> select sysdate, sysdate + interval '2 6' day to hour from dual;
SYSDATE SYSDATE+INTERVAL'26
------------------- -------------------
14/08/2007 16:13:49 16/08/2007 22:13:49
1 row selected.
Regards
Michel
|
|
|