Skip to main content development
   toolset
 
  Easy400   |       iSeries home
Public-Source
 
Introduction
Tutorial
Examples
FAQ
Index
Download
 
 

 
2.11 - Date functions


Some cgicbldev2 procedures (for instance the QCrtCookie procedure) require date-time stamps in the following timestamp format (26 char):
    yyyy-mm-dd-hh.mm.ss.xxxxxx
(where "xxxxxx" are microseconds).

  •  QCurrDate  - Retrieve the current date-time stamp
    This procedure returns a 26 char string containing the current date and time information (please note that this is NOT the timestamp related at the HTTP instance job initiation).
    No input is required.

    Example:
                ...         ...         ...
           SPECIAL-NAMES.
                 copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
                ...         ...         ...
          * Variable for QCurrDate procedure
               05     stampnow            PIC  X(26).
            ...         ...         ...
          * Retrieve the current date-time stamp
               call 'QCURRDATE' returning stampnow.


  •  QAddSubDur  - Add / subtract a duration to a date-time stamp
    This procedure allows to add an interval time (duration) to an input date-time stamp. It returns the resulting date-time stamp.
    Both the input and the returned date-time stamps have the format (char 26)
        yyyy-mm-dd-hh.mm.ss.xxxxxx
    (where "xxxxxx" are microseconds).
    All the following inputs are required:
    1. Input date-time stamp (char 26)
    2. Add / subtract operator (char 1), values '+' or '-'
    3. Number of years to be added/substracted (numeric)
    4. Number of months to be added/substracted (numeric)
    5. Number of days to be added/substracted (numeric)
    6. Number of hours to be added/subtracted (numeric)
    7. Number of minutes to be added/subtracted (numeric)
    8. Number of seconds to be added/substracted (numeric)
    Example:
                ...         ...         ...
           SPECIAL-NAMES.
                 copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
                ...         ...         ...
          * Variable for QCurrDate procedure
               05     stampnow            PIC  X(26).
          * Variables for QAddSubDur
               05     baseStamp           PIC  X(26).
               05     addSub              PIC  X(1) value '+'.
               05     addSubYears         PIC  S9(9) comp-4 value 0.
               05     addSubMonths        PIC  S9(9) comp-4 value 0.
               05     addSubDays          PIC  S9(9) comp-4 value 0.
               05     addSubHours         PIC  S9(9) comp-4 value 0.
               05     addSubMins          PIC  S9(9) comp-4 value 0.
               05     addSubSecs          PIC  S9(9) comp-4 value 0.
               05     retStamp            PIC  X(26).
            ...         ...         ...
          * Retrieve the current date-time stamp
               call 'QCURRDATE' returning stampnow.
          * Compute a date-time stamp three months ahead of now
               move stampnow to basestamp
               move '+' to addSub
               compute addSubMonths = 3
               call 'QADDSUBDUR' using basestamp
                                       addSub
                                       addSubYears
                                       addSubMonths
                                       addSubDays
                                       addSubHours
                                       addSubMins
                                       addSubSecs
                                 returning retstamp.



  •     Contact