View previous topic :: View next topic |
Author |
Message |
kris_madras Beginner
Joined: 07 Apr 2004 Posts: 46 Topics: 29
|
Posted: Thu May 13, 2004 6:58 am Post subject: Finding day of Cycle week |
|
|
Hi,
I have to check dates as follows...
If the transaction date is 010504(ddmmyy) i want to check whether this day(01) is friday or not? Is there any builtin function in cobol to do
this?
Thanks
krishna |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Thu May 13, 2004 7:46 am Post subject: |
|
|
Krismadras,
Please do not post the same topic in more than 1 forum. I am deleting your duplicate post. The following code will give you the dayname for any given date. I used to the window logic to populate the century portion of the date. However you can intrinsic functions like
DATE-TO-YYYYMMDD & YEAR-TO-YYYY to get the 4 digit year.
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. COBDAY
DATE-COMPILED.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-COB-DATE PIC 9(08).
01 WS-COB-DATE-R REDEFINES WS-COB-DATE.
05 WS-COB-CC PIC 9(02).
05 WS-COB-YY PIC 9(02).
05 WS-COB-MM PIC 9(02).
05 WS-COB-DD PIC 9(02).
01 WS-INP-DATE.
05 WS-INP-DD PIC 9(02).
05 WS-INP-MM PIC 9(02).
05 WS-INP-YY PIC 9(02).
01 WS-DIVIDE-ANSWER PIC S9(08) COMP.
01 WS-INTEGER PIC S9(08) COMP.
01 WS-REMAINDER PIC S9(04) COMP.
01 WS-DAY-OF-WEEK PIC X(09).
PROCEDURE DIVISION.
MOVE 010504 TO WS-INP-DATE
IF WS-INP-YY < 50
MOVE 20 TO WS-COB-CC
ELSE
MOVE 19 TO WS-COB-CC
END-IF
MOVE WS-INP-DD TO WS-COB-YY
MOVE WS-INP-MM TO WS-COB-MM
MOVE WS-INP-YY TO WS-COB-DD
COMPUTE WS-INTEGER = FUNCTION
INTEGER-OF-DATE(WS-COB-DATE)
DIVIDE WS-INTEGER BY 7 GIVING WS-DIVIDE-ANSWER
REMAINDER WS-REMAINDER
ADD 1 TO WS-REMAINDER
EVALUATE WS-REMAINDER
WHEN 1
MOVE 'SUNDAY ' TO WS-DAY-OF-WEEK
WHEN 2
MOVE 'MONDAY ' TO WS-DAY-OF-WEEK
WHEN 3
MOVE 'TUESDAY ' TO WS-DAY-OF-WEEK
WHEN 4
MOVE 'WEDNESDAY' TO WS-DAY-OF-WEEK
WHEN 5
MOVE 'THURSDAY ' TO WS-DAY-OF-WEEK
WHEN 6
MOVE 'FRIDAY ' TO WS-DAY-OF-WEEK
WHEN 7
MOVE 'SATURDAY ' TO WS-DAY-OF-WEEK
END-EVALUATE
DISPLAY 'IT IS A ' WS-DAY-OF-WEEK ' ON ' WS-INP-DATE
GOBACK.
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
|
|