How to find the Day of the week?
How to find the Day of the week?
In COBOL, given an input date, how can I find the Day of week? What logic can be used. Please advise.
- enrico-sorichetti
- Global Moderator
- Posts: 843
- Joined: Wed Sep 11, 2013 3:57 pm
Re: How to find the Day of the week?
the integer_of_date function returns an integer which has the peculiarity that
the remainder of the division by 7 ( modulus function )
gives the number of the day of the week 0-sunday .... 6-saturday
the remainder of the division by 7 ( modulus function )
gives the number of the day of the week 0-sunday .... 6-saturday
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort

Re: How to find the Day of the week?
Thanks Enrico.
IfI could a reference program it might just help me...though it's too much to ask...
IfI could a reference program it might just help me...though it's too much to ask...
-
- Former Team Member
- Posts: 62
- Joined: Wed Aug 07, 2013 6:43 pm
Re: How to find the Day of the week?
Hello,
Suggest you create a tiny test program to do this.
Post here when there are questions or problems.
You will learn more by doing and our goal is to help you learn.
Suggest you create a tiny test program to do this.
Post here when there are questions or problems.
You will learn more by doing and our goal is to help you learn.
Hope this helps,
d
d
-
- New Member
- Posts: 5
- Joined: Wed Jul 06, 2016 8:59 pm
Re: How to find the Day of the week?
Going through old topics, this may help new members or someone very lazy

Code: Select all
IDENTIFICATION DIVISION.
PROGRAM-ID. YOUR-PROGRAM-NAME.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
01 WS-IN-DATE PIC 9(8).
01 WS-IN-DATE-FUNC PIC 9(8).
01 WS-DAY-OF-WEEK PIC S9(08).
01 WS-QUOTIENT PIC S9(04).
01 WS-REMAINDER PIC S9(04).
PROCEDURE DIVISION.
MAIN-PROCEDURE.
DISPLAY "Enter the date(YYYYMMDD):"
ACCEPT WS-IN-DATE.
DISPLAY "Entered date is: "WS-IN-DATE.
COMPUTE WS-DAY-OF-WEEK = FUNCTION INTEGER-OF-DATE(WS-IN-DATE)
DIVIDE WS-DAY-OF-WEEK BY 7 GIVING WS-QUOTIENT
REMAINDER WS-REMAINDER
EVALUATE WS-REMAINDER
when 0
DISPLAY WS-IN-DATE " is Sunday"
when 1
DISPLAY WS-IN-DATE " is Monday"
when 2
DISPLAY WS-IN-DATE " is Tuesday"
when 3
DISPLAY WS-IN-DATE " is Wednesday"
when 4
DISPLAY WS-IN-DATE " is Thursday"
when 5
DISPLAY WS-IN-DATE " is Friday"
when 6
DISPLAY WS-IN-DATE " is Saturday"
END-EVALUATE.
STOP RUN.
-
- New Member
- Posts: 5
- Joined: Wed Jul 06, 2016 8:59 pm
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute