View previous topic :: View next topic
|
Author |
Message |
kedianirmal
New User
Joined: 08 Feb 2008 Posts: 82 Location: Bangalore, India
|
|
|
|
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 |
|
|
kedianirmal
New User
Joined: 08 Feb 2008 Posts: 82 Location: Bangalore, India
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Start with function MOD against the function INTEGER-OF-DATE of the function CURRENT-DATE...... |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
kedianirmal
New User
Joined: 08 Feb 2008 Posts: 82 Location: Bangalore, India
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
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 |
|
|
|