View previous topic :: View next topic |
Author |
Message |
deep81this Beginner
Joined: 26 Apr 2011 Posts: 4 Topics: 2
|
Posted: Thu May 10, 2012 4:04 am Post subject: Getting Second Sunday of March and First Sunday of November |
|
|
Hi,
Could any one help me. My requirement is to get the Second Sunday (date) of March and first Sunday of November of any year using SQL query alone. DB2 version is 9.0.
Thanks in advance,
Deepthi |
|
Back to top |
|
|
Sqlcode Intermediate
Joined: 15 Dec 2006 Posts: 157 Topics: 38
|
Posted: Thu May 10, 2012 9:30 am Post subject: |
|
|
deep81this,
Do you have calendar table built already?
Thanks, |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Thu May 10, 2012 10:39 am Post subject: |
|
|
deep81this,
Try this untested sql for the year 2012. You can build the date of FEB 1st and OCT 31st for any year and get the results.
Code: |
SELECT DATE(NEXT_DAY(LAST_DAY('2012-02-01'),'SUN') + 7 DAYS)
,DATE(NEXT_DAY(DATE('2012-10-31')),'SUN')
FROM SYSIBM.SYSDUMMY1
; |
Kolusu |
|
Back to top |
|
|
deep81this Beginner
Joined: 26 Apr 2011 Posts: 4 Topics: 2
|
Posted: Mon Jun 04, 2012 12:59 am Post subject: |
|
|
thanku Kolusu, it worked for ur sql as
Code: |
SELECT DATE(NEXT_DAY(LAST_DAY('2013-02-01'),'SUN') + 7 DAYS)
,DATE(NEXT_DAY(DATE('2013-10-31'),'SUN'))
FROM SYSIBM.SYSDUMMY1
;
|
sorry for the late reply.... |
|
Back to top |
|
|
|
|