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

How to calculate the Week Number for a given date?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
tony01
Currently Banned

New User


Joined: 14 Sep 2005
Posts: 9

PostPosted: Sat Nov 11, 2006 10:24 am
Reply with quote

DavidatK:

I tested year 2000 (leap year) for December 3th, 2000
I got weeknum = 49, which is wrong , should be weeknum = 48

December 30th, 2000
I got 2001-01, which is wrong , should be 2000-52

December 31st, 2000
I got 2001-01, which is wrong , should be 2000-52

In fact the code is NOT STABLE, I think is missing more logic, but should be tricki.

Anayway, still looking a TRUE solution.

Thanks

Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Nov 14, 2006 5:25 am
Reply with quote

Tony01,

I've got to stand by this code being correct. I even backloaded the code I posted and compiled that. Results of that test are:

Code:

.20001201 = 2000-48
.20001202 = 2000-48
.20001203 = 2000-48
.20001204 = 2000-49
.20001205 = 2000-49
.20001229 = 2000-52
.20001230 = 2000-52
.20001231 = 2000-52
.20010101 = 2001-01


Methinks you missed something when you copied the code icon_smile.gif

What compiler are you using?

Dave
Back to top
View user's profile Send private message
tony01
Currently Banned

New User


Joined: 14 Sep 2005
Posts: 9

PostPosted: Tue Nov 14, 2006 7:31 am
Reply with quote

Hi Dave:

In fact, I am working with Mainframe os/390, but the problem I think is that I don't have the FUNCTION INTGER-OF-DATE , so I am using a home routine to calculate INTEGR-OF-DATE, maybe this is the problem.
I am not sure of that.

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

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Wed Nov 15, 2006 1:30 am
Reply with quote

Tony01,

One of the common problems with calculating the integer-of-date is that most applications are concerned with the number of days between two given dates within a normal business environment, where you are normally not concerned with dates prior to 1901 or after 2099 and are not concerned with the day of the week. The error usually comes in when calculating leap-years. Normally we consider a leap year to be a year evenly divisible by 4, and for the year between 1901 and 2099 this is true. However, if the year is evenly divisible by 100 and not evenly divisible by 400, it is NOT a leap year. Hence, 1600, 2000, 2400 are leap years, 1700, 1800, 1900, 2100 are NOT leap years. If this is not taken into account and your base year is prior to 1901, the day of the week is thrown off. Check your home code for integer-of-year to make sure it takes this into account.

Dave
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Nov 15, 2006 3:07 am
Reply with quote

Dave,

excellent response, the technical was right on; i am envious of your diplomatic skills.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Fri Dec 01, 2006 6:59 am
Reply with quote

Tony01,

Did you ever find a solution to your query?

Dave
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 Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
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
Search our Forums:

Back to Top