Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

logic for last sat and sun

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
akshaiya

New User


Joined: 17 Sep 2005
Posts: 49

PostPosted: Wed Jun 14, 2006 2:54 pm    Post subject: logic for last sat and sun
Reply with quote

how to find last saturday and sunday of every month....
Can anyone give me the logic to include in cobol.
Back to top
View user's profile Send private message

parikshit123

Active User


Joined: 01 Jul 2005
Posts: 269
Location: India

PostPosted: Thu Jun 15, 2006 4:13 pm    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Jun 22, 2006 7:42 am    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
hikaps14

Active User


Joined: 02 Sep 2005
Posts: 189
Location: Noida

PostPosted: Thu Jun 22, 2006 12:25 pm    Post subject: Re: logic for last sat and sun
Reply with quote

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.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Wildcard logic in COBOL dudenithy COBOL Programming 13 Thu Sep 01, 2016 7:36 pm
No new posts Sort Logic to extract data scorp_rahul23 DFSORT/ICETOOL 13 Tue Mar 01, 2016 1:22 am
No new posts Need a logic to validate the data in ... sandeep kumar302 COBOL Programming 17 Mon Feb 01, 2016 3:30 pm
No new posts Tricky sort logic required pgopi92 DFSORT/ICETOOL 3 Mon Jan 25, 2016 3:29 pm
No new posts DB2 - CURRENT DATE + 2 YRS logic balaji81_k DB2 3 Thu Nov 26, 2015 3:07 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us