MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Getting Second Sunday of March and First Sunday of November

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
deep81this
Beginner


Joined: 26 Apr 2011
Posts: 4
Topics: 2

PostPosted: Thu May 10, 2012 4:04 am    Post subject: Getting Second Sunday of March and First Sunday of November Reply with quote

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
View user's profile Send private message
Sqlcode
Intermediate


Joined: 15 Dec 2006
Posts: 157
Topics: 38

PostPosted: Thu May 10, 2012 9:30 am    Post subject: Reply with quote

deep81this,

Do you have calendar table built already?

Thanks,
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Thu May 10, 2012 10:39 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
deep81this
Beginner


Joined: 26 Apr 2011
Posts: 4
Topics: 2

PostPosted: Mon Jun 04, 2012 12:59 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group