ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

fmtdate procedure example

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • fmtdate procedure example

    This is another example of a procedure to return date type info
    from a passed in date.

    there are three inbound parms (1) a date
    (2) days to add/subtract from date
    (3) include weekends when parm 2 specified

    all three parameters are optional.
    if a date is not passed then todays date will be used

    Whats returned is:

    * What is returned
    * EVAL date
    * DATE.ERROR = 'N'
    * DATE.ISO = '2007-08-01'
    * DATE.MDY = '08/01/07'
    * DATE.USA = '08/01/2007'
    * DATE.ISO0 = 20070801.
    * DATE.MDY0 = 080107.
    * DATE.USA0 = 08012007.
    * DATE.JUL0 = 2454314.
    * DATE.DAYNAME = 'Wednesday'
    * DATE.MONTHNAME = 'August '
    * DATE.LSTDAYCUR = '2007-08-31'
    * DATE.LSTDAYCURISO = 20070831.
    * DATE.LSTDAYCURMDY = 083107.
    * DATE.LSTDAYCURCYMD = 1070831.
    * DATE.FSTDAYCUR = '2007-08-01'
    * DATE.FSTDAYCURISO = 20070801.
    * DATE.FSTDAYCURMDY = 080107.
    * DATE.FSTDAYCURCYMD = 1070801.
    *
    * DATE.LSTDAYLST = '2007-07-31'
    * DATE.LSTDAYLSTISO = 20070731.
    * DATE.LSTDAYLSTMDY = 073107.
    * DATE.LSTDAYLSTCYMD = 1070731.
    * DATE.FSTDAYLST = '2007-07-01'
    * DATE.FSTDAYLSTISO = 20070701.
    * DATE.FSTDAYLSTMDY = 070107.
    * DATE.FSTDAYLSTCYMD = 1070701.
    *
    * DATE.STRING1 = '01 Aug 2007 '
    * DATE.STRING2 = 'Wednesday, 01 Aug 2007 '
    * DATE.STRING3 = 'Wednesday, 01 August 2007 '
    * DATE.TIME = '16.05.03'
    * DATE.TIMESTAMP = '2007-08-01-16.05.03.000000'
    * DATE.WORKISO = '2007-07-01'


    *** This is just an example and may contain errors as well as need
    more returned info added. Please feel free to do this and repost
    so that others may benefit from your efforts.


    first create a source file called source (or change copy book).

    CRTSRCPF mylib/source rcdlen(112)

    then using your favorite method get the 4 source members for this
    example into this source file.


    compile the member CVTDATE first using option 15
    PHP Code:
    CRTSQLRPGI OBJ(JAMIELIB/FMTDATESRCFILE(JAMIELIB/SOURCE)
    OBJTYPE(*MODULE
    Then create the test programs there is one RPGLE and one CLLE

    RPGLE

    PHP Code:
    CRTRPGMOD MODULE(JAMIELIB/FMTDATTSTSRCFILE(JAMIELIB/SOURCE
    PHP Code:
    crtpgm fmtdattst module(fmtdattst fmtdate

    CLLE

    PHP Code:
    CRTCLMOD  MODULE(JAMIELIB/FMTDATTST2
    SRCFILE(JAMIELIB/SOURCE
    PHP Code:
    crtpgm fmtdattest module(fmtdattst fmtdate

    then use debug to see the returned values.

    Ive included a v5r3 savefile for your pleasure
    library saved from is FMTDATE
    cant compile FMTDATTST2 cause I dont have CLLE back
    version compile program...so your on your own.




    ~
    Attached Files
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

  • #2
    Re: fmtdate procedure example

    this will give you just the day.......... in format of "Friday" and month name "September"

    Code:
         d CEEDATE         PR                  opdesc
         d   Lilian                      10i 0
         d   picture                  65535A   const options(*varsize)
         d   OutputDate               65535A   const options(*varsize)
         d   Feedback                    12a   options(*omit)
    
    
         d today           S               D   INZ(*SYS)
         d BaseDate        S               D   INZ(D'1582-10-14')
         d nDays           S             10I 0
         d myDate          S             12A
    
          /free
              //Friday         
                 nDays = %diff(today : baseDate : *Days);
                 ceedate(nDays:'Wwwwwwwwwz':myDate:*OMIT);
             //September                                    
                 nDays = %diff(today : baseDate : *Days);   
                 ceedate(nDays:'Mmmmmmmmmm':myDate:*OMIT);  
                                                     
    
                 *inlr = *on;
          /end-free
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: fmtdate procedure example

      Another easy way to get the day of week name

      Code:
      EXEC SQL Set :DayName = DAYNAME(Checkdate);

      Comment

      Working...
      X