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

How to get the week number


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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: 2146
Location: At my coffee table

PostPosted: Sat Apr 11, 2009 12:00 am
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Apr 11, 2009 12:00 am
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
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: 2146
Location: At my coffee table

PostPosted: Sat Apr 11, 2009 12:07 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Increase the number of columns in the... IBM Tools 3
No new posts Cobol program with sequence number ra... COBOL Programming 5
Search our Forums:

Back to Top