Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
akshaiya

New User

Joined: 17 Sep 2005
Posts: 49

 Posted: Wed Jun 14, 2006 2:54 pm    Post subject: logic for last sat and sun how to find last saturday and sunday of every month.... Can anyone give me the logic to include in cobol.

parikshit123

Active User

Joined: 01 Jul 2005
Posts: 269
Location: India

 Posted: Thu Jun 15, 2006 4:13 pm    Post subject: Hi, To add to that, complexity of leap years also needs to be taken into consideration.! Its really a tough problem. At least not a cake walk for sure.
mmwife

Super Moderator

Joined: 30 May 2003
Posts: 1592

 Posted: Thu Jun 22, 2006 7:42 am    Post subject: Here's one possibility: Set up a wrk date CCYYMMDD. Move your date to wrk date. Add 1 to wrk-mm. move 01 to wrk-dd. compute int-date = function (integer of date (wrk-date)) - 1 int-date now has the int for the last day of your month divide int-date by 7 giving ws-dummy-fld remainder ws-rem If ws-rem = 0 it's a sunday; if 1 it's a mon; etc. subtract ws-rem from int-date That gives you the int for the last sunday in the month. Then do a function (date of integer) for int-date. That gives you the CCYYMMDD for the last sunday. Then subtract 1 from sunday's DD to get the last Saturday of the month date. Not sure of the syntax of the date functions but the logic looks OK.
hikaps14

Active User

Joined: 02 Sep 2005
Posts: 189
Location: Noida

 Posted: Thu Jun 22, 2006 12:25 pm    Post subject: Re: logic for last sat and sun Hi , I hav also 1 SOL. if u want to find all end of month sat. sun of whole year . start with first day of year . Logic: 1.Find out DATE of first saturday of month. 2.keep on adding 7 to its date and keep on checking with with no. of days left for End month . if its less than 7 and Gr than 0 then we are at end sat and sun, if its more than 7 then add 7 go to start of loop again . it its equal to zero (sat is itself last day of month ) then we can subtract 6 and get last sun . but for this code u need to cal. no. of days in that month in advance . then only u can compare . i hope u get this . Thanks , Kapil.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Logic to skip Maximum time-stamp and ... vickey_dw DB2 2 Thu Feb 01, 2018 11:15 pm Is CICS BMS logic on z/OS different ... Andi1982 CICS 2 Fri Dec 01, 2017 1:56 pm Need help in building a logic Benchwarmer All Other Mainframe Topics 4 Wed Feb 22, 2017 2:49 am Wildcard logic in COBOL dudenithy COBOL Programming 13 Thu Sep 01, 2016 7:36 pm Sort Logic to extract data scorp_rahul23 DFSORT/ICETOOL 13 Tue Mar 01, 2016 1:22 am

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us