## How to find the day of the Date ?

IBM's cross-platform compiler PL/I for MVS, VM & VSE, OS/390 and Enterprise PL/I for z/OS

### How to find the day of the Date ?

Hi all,
I want to write a PL/I program on how to find the "day of the date".
I know how to fetch the date from the system date.
But I want to know is there any function to convert the date's day(number) into day of the week.
Please guide me on building the logic.

Any help would be appreciated.

Thank you,
Siddu
bobbysiddu

Posts: 3
Joined: Mon Jul 08, 2013 11:45 am
Has thanked: 0 time
Been thanked: 0 time

### Re: How to find the day of the Date ?

SELECT
CASE
WHEN DAYOFWEEK(CURRENT TIMESTAMP) = 1 THEN 'SUNDAY'
WHEN DAYOFWEEK(CURRENT TIMESTAMP) = 2 THEN 'MONDAY'
WHEN DAYOFWEEK(CURRENT TIMESTAMP) = 3 THEN 'TUESDAY'
WHEN DAYOFWEEK(CURRENT TIMESTAMP) = 4 THEN 'WEDNESDAY'
WHEN DAYOFWEEK(CURRENT TIMESTAMP) = 5 THEN 'THURSDAY'
WHEN DAYOFWEEK(CURRENT TIMESTAMP) = 6 THEN 'FRIDAY'
ELSE                                       'SATURDAY'
END
FROM SYSIBM.SYSDUMMY1;
There are 10 types of people in the world: Those who understand binary, and those who don't.

Stefan

Posts: 27
Joined: Tue Aug 21, 2012 3:02 pm
Has thanked: 0 time
Been thanked: 2 times

### Re: How to find the day of the Date ?

Thank you Stefan...
bobbysiddu

Posts: 3
Joined: Mon Jul 08, 2013 11:45 am
Has thanked: 0 time
Been thanked: 0 time

### Re: How to find the day of the Date ?

Stefan wrote:
SELECT
CASE
WHEN DAYOFWEEK(CURRENT TIMESTAMP) = 1 THEN 'SUNDAY'
WHEN DAYOFWEEK(CURRENT TIMESTAMP) = 2 THEN 'MONDAY'
WHEN DAYOFWEEK(CURRENT TIMESTAMP) = 3 THEN 'TUESDAY'
WHEN DAYOFWEEK(CURRENT TIMESTAMP) = 4 THEN 'WEDNESDAY'
WHEN DAYOFWEEK(CURRENT TIMESTAMP) = 5 THEN 'THURSDAY'
WHEN DAYOFWEEK(CURRENT TIMESTAMP) = 6 THEN 'FRIDAY'
ELSE                                       'SATURDAY'
END
FROM SYSIBM.SYSDUMMY1;

Is that not rather a SQL solution than a PL/I one?
dcl dayofweek char (90;
select (weekday());
when (1) dayofweek = 'Sunday';
when (2) dayofweek = 'Monday';
when (3) dayofweek = 'Tuesday';
when (4) dayofweek = 'Wednesday';
when (5) dayofweek = 'Thursday';
when (6) dayofweek = 'Friday';
when (7) dayofweek = 'Saturday';
end
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day

Akatsukami
Global moderator

Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

### Re: How to find the day of the Date ?

Yes.
I executed the code..
It does look like a SQL code.
Will try with other logic(mentioned by Akatsukami) and reply..
Thank you.
bobbysiddu

Posts: 3
Joined: Mon Jul 08, 2013 11:45 am
Has thanked: 0 time
Been thanked: 0 time