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
 

 

How to get the week number

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

New User


Joined: 08 Feb 2008
Posts: 82
Location: Bangalore, India

PostPosted: Fri Apr 10, 2009 11:49 pm    Post subject: How to get the week number
Reply with quote

Hi,

Could you please help me to know how to get the current week number in the cobol program.
The week count starts from the Jan 1st Sunday.


Thanks,
Nirmal
Back to top
View user's profile Send private message

kedianirmal

New User


Joined: 08 Feb 2008
Posts: 82
Location: Bangalore, India

PostPosted: Fri Apr 10, 2009 11:58 pm    Post subject:
Reply with quote

And also how to get the start and end date of that week i.e. the date on Sunday and Saturday in that week.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Sat Apr 11, 2009 12:00 am    Post subject:
Reply with quote

Start with function MOD against the function INTEGER-OF-DATE of the function CURRENT-DATE......
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7932
Location: Bellevue, IA

PostPosted: Sat Apr 11, 2009 12:00 am    Post subject:
Reply with quote

Okay, in 2009 January 1st was a Thursday, not a Sunday. So when does week 1 begin for 2009?

There's a link to the manuals at the top of the page. Pull up the COBOL Language Reference and look at the INTEGER-OF-DATE and DAY-OF-INTEGER functions. With a couple of conversions and a little integer arithmetic, it isn't hard to derive the week number from a date.
Back to top
View user's profile Send private message
kedianirmal

New User


Joined: 08 Feb 2008
Posts: 82
Location: Bangalore, India

PostPosted: Sat Apr 11, 2009 12:03 am    Post subject:
Reply with quote

If the 1st Jan is in Mid of the week then the week one will start from the December date lying on the Sunday.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Sat Apr 11, 2009 12:07 am    Post subject:
Reply with quote

kedianirmal wrote:
And also how to get the start and end date of that week i.e. the date on Sunday and Saturday in that week.
Once you know the day of the week, add 7-dow and subtract dow to the interger of date to get the last and first....
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 How to find the first monday of the w... abdulrafi COBOL Programming 10 Fri Nov 25, 2016 3:24 pm
No new posts Sequence number add in SORT pshongal SYNCSORT 3 Fri Sep 02, 2016 3:32 pm
No new posts Casting a Binary Number to Numeric in... Bob Steinkraus Java & MQSeries 6 Tue Aug 09, 2016 5:58 pm
No new posts GDG vsersion number change Raghu navaikulam JCL & VSAM 5 Fri May 27, 2016 4:49 pm
No new posts CPU time Vs Number of records Nileshkul JCL & VSAM 5 Mon May 09, 2016 4:05 pm


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