| 
 | 
Here's what I worked up (It's RPG/IV, old). I use it to return variables to
a CL program.
RTVDOW - command
RTVDOWR - RPGLE command processor
RTVDOWH - command help (panel group)
Compile RTVDOWR & RTVDOWH with 14 compile
Create command RTVDOW with these parameters:
PGM(RTVDOWR) HLPPNLGRP(RTVDOWH) HLPID(RTVDOW)
It's worked for me.
Loyd
********** RTVDOW type CMD
********** Input type: date
********** Output type: day of the week: *SUN, *MON, *TUE, *WED, *THU, *FRI,
*SAT
CMD        PROMPT('Retrieve day of week')                 
PARM       KWD(DATE) TYPE(*DATE) DFT(*CURRENT) +          
             SPCVAL((*CURRENT 0000001)) PROMPT('Date +    
             to retrieve DOW')                            
PARM       KWD(DOW) TYPE(*CHAR) LEN(4) RTNVAL(*YES) +     
             MIN(1) PROMPT('Return var for DOW (*CHAR 4)')
********** RTVDOWR type RPGLE
      *-- Parameters                                           
     d indate          s              7                        
     d outdow          s              4                        
                                                               
      *-- Variables                                            
     d wkdate          s               d   datfmt(*jul)        
     d wkdate2         s              6  0 inz                 
     d wkdate5         s              5  0 inz                 
     d numdow          s              1  0 inz                 
     d curdate         s              8  0 inz                 
     d timestamp       s             14  0 inz                 
                                                               
      *-- Data structure                                       
     d                 ds                                      
     d  juldat                 1      6  0 inz                 
     d  julcyy                 1      3  0                     
     d  julddd                 4      6  0                     
                                                               
     c     *entry        plist                                 
     c                   parm                    indate          
     c                   parm                    outdow          
                                                                 
     c                   if        indate = '0000001'            
     c                   time                    timestamp       
     c                   move      timestamp     curdate         
     c     *usa          move      curdate       wkdate          
     c                   else                                    
     c     *cymd0        move      indate        wkdate          
     c                   endif                                   
                                                                 
     c     *jul          move      wkdate        wkdate2         
     c                   move      wkdate2       juldat          
                                                                 
     c     julcyy        sub       1             wkdate5         
     c                   mult      365.25        wkdate5         
     c                   add       365           wkdate5         
     c                   add       julddd        wkdate5         
     c     wkdate5       div       7             numdow          
     c                   mvr                     numdow          
     c                   add       1             numdow      
                                                             
     c                   select                              
     c                   when      numdow = 1                
     c                   eval      outdow = '*SUN'           
     c                   when      numdow = 2                
     c                   eval      outdow = '*MON'           
     c                   when      numdow = 3                
     c                   eval      outdow = '*TUE'           
     c                   when      numdow = 4                
     c                   eval      outdow = '*WED'           
     c                   when      numdow = 5                
     c                   eval      outdow = '*THU'           
     c                   when      numdow = 6                
     c                   eval      outdow = '*FRI'           
     c                   when      numdow = 7                
     c                   eval      outdow = '*SAT'           
     c                   endsl                               
                                                    
     c                   eval      *inlr = *on      
********** RTVDOWH type PNLGRP
:pnlgrp.
:help name='RTVDOW'.Retrieve Day of Week - Help
:p.The Retrieve Day of Week (RTVDOW) command retrieves the day of the week
for  
a specific date.
:ehelp.
:help name='RTVDOW/DATE'.Date to retrieve DOW (DATE) - Help
:xh3.Date to retrieve DOW (DATE)
:p.Specify the date for which to retrieve the day of the week.
:p.The possible values are:
:parml.
:pt.:pk def.*CURRENT:epk.
:pd.The current date will be used.
:pt.:pk.date:epk.
:pd.Specify a date for which to retreive the day of the week.
:nt.The date will be validated according to OS/400 date validation rules.
:ent.
:eparml.
:ehelp.
:help name='RTVDOW/DOW'.Return var for DOW (DOW) - Help
:xh3.Return var for DOW (DOW)
:p.Specify the return variable that will contain the day of the week for
the date specified in the DATE parameter.
:p.This variable should be specified as character format, four positions.
:p.One of the following values will be placed in the variable, representing
the 
day of the week:
:ul compact.
:li.:hp2.*MON:ehp2.  Monday
:li.:hp2.*TUE:ehp2.  Tuesday
:li.:hp2.*WED:ehp2.  Wednesday
:li.:hp2.*THU:ehp2.  Thursday
:li.:hp2.*FRI:ehp2.  Friday
:li.:hp2.*SAT:ehp2.  Saturday
:li.:hp2.*SUN:ehp2.  Sunday
:eul.
:ehelp.
:epnlgrp.
********** END OF SOURCE
> -----Original Message-----
> From: Klein Ron [SMTP:ron.klein@brctsg.com]
> Sent: Thursday, 09 December, 1999 10:36 AM
> To:   'MIDRANGE-L (E-mail)
> Subject:      Day of the week
> 
> Hi all,
> 
> Since we have a discusion going about the days of the month, how about a
> easy routine to find the day of the week?  Any one have a solution?
> 
> TIA
> Ron
> +---
> | This is the Midrange System Mailing List!
> | To submit a new message, send your mail to MIDRANGE-L@midrange.com.
> | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
> | To unsubscribe from this list send email to
> MIDRANGE-L-UNSUB@midrange.com.
> | Questions should be directed to the list owner/operator:
> david@midrange.com
> +---
+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.