× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



This is a multipart message in MIME format.
--
[ Picked text/plain from multipart/alternative ]
Normally there are some subprocedures to do this.  This is the beauty of
RPGLE.  Can't find a bif?  Make your own!

Here are three subprocedures:
DayOfWeek will convert a date into a day of the week.
DayNameL will convert a day of the week into a long name, 1=Monday,
2=Tuesday...
DayNameS will convert a day of the week into a short name, 1=Mon, 2=Tue...
Sample use:
     C                  Eval      DispDay=DayNameS(DayOfWeek(mydate))

(and the use of Code/400 makes copying and pasting the following code so
much easier than SEU).

      /eject
     P     DayOfWeek   B                   EXPORT
      ***** DayOfWeek - Calculates day of week (Monday = 1, Tuesday = 2,
etc.)
      *               - for any date.
      *               - Input:  WorkDate (Date field in *USA format)
      *               - Result: WorkDay  (Single digit numeric)
     D                 PI             1S 0
     D WorkDate                        D   CONST
     D AnySunday       S               D   INZ(D'04/02/1995')
     D WorkNum         S              7  0
     D WorkDay         S              1S 0


     C     WorkDate      SubDur    AnySunday     WorkNum:*D

     C     WorkNum       Div       7             WorkNum
     C                   MvR                     WorkDay

     C                   If        WorkDay < 1
     C                   Return    WorkDay + 7
     C                   Else
     C                   Return    WorkDay
     C                   EndIf

     P     DayOfWeek   E


      /eject
     P     DayNameL    B                   EXPORT
     D DayNameL        PI             9A
     D  WorkDate                       D   CONST

     D                 DS
     D DayData                       42    Inz('Mon   Tues  Wednes+
     D                                          Thurs Fri   Satur Sun   ')
     D DayArray                       6    Overlay(DayData) Dim(7)

     C                   Return    %TrimR(DayArray(DayOfWeek(WorkDate))) +
     C                             'day'

     P     DayNameL    E


      /eject
     P     DayNameS    B                   EXPORT
     D DayNameS        PI             3A
     D  WorkDate                       D   CONST

     D                 DS
     D DayData                       21    Inz('MonTueWedThuFriSatSun')
     D DayArray                       3    Overlay(DayData) Dim(7)

     C                   Return    %TrimR(DayArray(DayOfWeek(WorkDate)))

     P     DayNameS    E

Rob Berendt
--
"They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety."
Benjamin Franklin




"Weeks, Glenn" <GWeeks@Sallybeauty.com>
Sent by: rpg400-l-admin@midrange.com
12/10/2002 05:27 PM
Please respond to rpg400-l

        To:     "'rpg400-l@midrange.com'" <rpg400-l@midrange.com>
        cc:
        Fax to:
        Subject:        Day of the week


If I know the date, 20021215 for instance, is there an easy way to
determine
the day of the week, (Monday, Tuesday, etc..). I cannot find an example of
this in any of the documentation that we have or any online documentaion.

Any help would be appreciated.

Thanks,.

Glen Weeks
Ex. 7771


_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l
or email: RPG400-L-request@midrange.com
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 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.