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
bobbysiddu
Posts: 3
Joined: Mon Jul 08, 2013 11:45 am
Skillset: Cobol, Pli, JCL, CICS, VSAM, DB2
Referer: Google

How to find the day of the Date ?

Postby bobbysiddu » Mon Jul 08, 2013 11:58 am

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

User avatar
Stefan
Posts: 27
Joined: Tue Aug 21, 2012 3:02 pm
Skillset: Application development, configuration management, maintaining test environments
Referer: world wide web

Re: How to find the day of the Date ?

Postby Stefan » Mon Jul 08, 2013 12:14 pm

Code: Select all

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.

bobbysiddu
Posts: 3
Joined: Mon Jul 08, 2013 11:45 am
Skillset: Cobol, Pli, JCL, CICS, VSAM, DB2
Referer: Google

Re: How to find the day of the Date ?

Postby bobbysiddu » Mon Jul 08, 2013 2:13 pm

Thank you Stefan... :-)

User avatar
Akatsukami
Global moderator
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Skillset: Rexx, JCL, DB2/SQL, TSO/ISPF, PL/I
Referer: ibmmainframes
Location: Bloomington, IL
Contact:

Re: How to find the day of the Date ?

Postby Akatsukami » Mon Jul 08, 2013 3:08 pm

Stefan wrote:

Code: Select all

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?

Code: Select all

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

bobbysiddu
Posts: 3
Joined: Mon Jul 08, 2013 11:45 am
Skillset: Cobol, Pli, JCL, CICS, VSAM, DB2
Referer: Google

Re: How to find the day of the Date ?

Postby bobbysiddu » Mon Jul 08, 2013 6:17 pm

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


  • Similar Topics
    Replies
    Views
    Last post