View previous topic :: View next topic
|
Author |
Message |
dejunzhu
Active User
Joined: 08 May 2008 Posts: 390 Location: China
|
|
|
|
given a day ,say ' 20130405' , how can I know which day is it within a week? MONDAY? TUESDAY? WEDNESDAY?THURSDAY? FRIDAY? SATURDAY? OR SUNDAY? |
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
Back to top |
|
|
Peter cobolskolan
Active User
Joined: 06 Feb 2012 Posts: 104 Location: Sweden
|
|
|
|
There is nothing than programming that solves the problem.
I recommend You read about COBOL Intrinsic Functions and date-functions.
Here is a small program example:
Code: |
Identification Division.
Program-ID. DAYNAME.
Data Division.
Working-Storage Section.
* Change to your date
01 TheDate Pic 9(08) Value 20120315.
77 TheDay Pic 9(01) Binary.
01 TheTable.
05 TheDays.
10 Pic X(09) Value 'Monday'.
10 Pic X(09) Value 'Tuesday'.
10 Pic X(09) Value 'Wednesday'.
10 Pic X(09) Value 'Thursday'.
10 Pic X(09) Value 'Friday'.
10 Pic X(09) Value 'Saturday'.
10 Pic X(09) Value 'Sunday'.
02 TheDaytab Redefines TheDays.
05 TheDayName Pic X(09) Occurs 7.
Procedure Division.
Compute
TheDay =
Function Rem(Function Integer-Of-Date(TheDate), 7)
End-Compute
If TheDate = 0
Move 7 to TheDay
End-If
Display 'The name of the day is: ' TheDayName(TheDay)
GoBack
. |
|
|
Back to top |
|
|
|