View previous topic :: View next topic |
Author |
Message |
NASCAR9 Intermediate
Joined: 08 Oct 2004 Posts: 274 Topics: 52 Location: California
|
Posted: Tue Jun 27, 2006 1:55 pm Post subject: Last Day with leap year |
|
|
Can someone else run this query and see if the return is 2004-02-29?
Code: |
SELECT DATE(LAST_DAY('1986-02-05' )) + 18 YEARS
FROM SYSIBM.SYSDUMMY1;
---------+---------+---------+---------+---------+---------+
---------+---------+---------+---------+---------+---------+
2004-02-28
DSNE610I NUMBER OF ROWS DISPLAYED IS 1
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
|
_________________ Thanks,
NASCAR9 |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Tue Jun 27, 2006 2:26 pm Post subject: |
|
|
NASCAR9,
You are using the LAST_DAY on the Inner date (1986-02-05) which will yield 1986-02-28 ( as 1986 is not leap year) . You are adding 18 years to 1986-02-28 , so you would always result in 2004-02-28. Change your sql to the following
Code: |
SELECT LAST_DAY(DATE('1986-02-05' ) + 18 YEARS)
FROM SYSIBM.SYSDUMMY1;
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
NASCAR9 Intermediate
Joined: 08 Oct 2004 Posts: 274 Topics: 52 Location: California
|
Posted: Tue Jun 27, 2006 2:33 pm Post subject: |
|
|
Kolusu,
Once again you have the answer.
Thank You! _________________ Thanks,
NASCAR9 |
|
Back to top |
|
 |
|
|