IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

logic for last sat and sun


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Finding faulty logic Subscript out of... COBOL Programming 5
This topic is locked: you cannot edit posts or make replies. Need assistance in job scheduling logic. Mainframe Interview Questions 2
No new posts Rexx Logic error while adding seperat... CLIST & REXX 3
No new posts PL/1 Callback address logic in z/OS C... PL/I & Assembler 1
No new posts Sync logic between VSAM files and DB2... COBOL Programming 9
Search our Forums:

Back to Top