DATE & TIME – OTHER IMPORTANT NOTES




DATE & TIME – OTHER IMPORTANT NOTES


2-digit - *LOVAL 1940 and *HIVAL 2039
*MDY – mm/dd/yy
*DMY – dd/mm/yy
*YMD – yy/mm/dd
*JUL – yy/days
4-digit = *LOVAL 0001 and *HIVAL 9999
*ISO – yyyy-mm-dd
*USA – mm/dd/yyyy
*EUR – dd.mm.yyyy
*JIS – yyyy-mm-dd
Externally defined date formats and separators
*CYMD – cyy/mm/dd
*CDMY – cdd/mm/yy
*CMDY – cmm/dd/yy
*LONGJUL – yyyy/ddd
Notes:
  1. *JOBRUN is valid only for character or numeric dates with a 2-digit year since the run-time job attribute for DATFMT can only be *MDY, *YMD, *DMY or *JUL.
  2. Valid values for the century character 'c' are:
             'c'           Years
         -----------------------
              0          1900-1999
              1          2000-2099
              .              .
              9          2800-2899
·     A slash (/) as a date separator
·     A hyphen (-) as a date separator
·     A period (.) as a date separator
·     A comma (,) as a date separator
·     A blank ( ) as a date separator

*HMS = *JIS = hh:mm:ss       00:00:00 and 24:00:00
*ISO = *EUR = hh.mm.ss      00.00.00 and 24.00.00
*USA = hh:mm AM               00:00 Am and 12:00 AM

YYYY-MM-DD-HH.MM.SS.MMMMMM (Length 26).

Declaring a Date:
H TIMFMT(*USA) DATFMT(*MDY&)
DLoandate         S               D   DATFMT(*EUR) INZ(D'12 31 92')

BIF’s and Duration codes
Unit
Built-In Function
Duration Code
Year
%YEARS
*YEARS or *Y
Month
%MONTHS
*MONTHS or *M
Day
%DAYS
*DAYS or *D
Hour
%HOURS
*HOURS or *H
Minute
%MINUTES
*MINUTES or *MN
Second
%SECONDS
*SECONDS or *S
Microsecond
%MSECONDS
*MSECONDS or *MS

Subset of Date                                    %SUBDT
Difference                               %DIFF
%DIFF(op1:op2:*MSECONDS|*SECONDS|*MINUTES|*HOURS|*DAYS|*MONTHS|*YEARS)
|%DIFF(op1:op2:*MS|*S|*MN|*H|*D|*M|*Y)

ADDDUR:
Factor1            ADDDUR      DURATION:DURATIONCODE     Result
E.g.,
LOANDATE      ADDDUR    XX:*YEARS     DUEDATE

SUBDUR:
Date/time        SUBDUR       Date/time                                Duration:duration code
Date/time        SUBDUR       duration:duration code           date/time

MOVE and MOVEL:
You can move between Date, time, timestamp, character and numeric.
Factor 1 is left blank in same data type moves.

TEST:
                        TEST(E)                                                          Date/time/timestamp               ER      
Date FMT       TEST(D E)                                                      Character or Numeric              ER
Time FMT       TEST(E T)                                                       Character or Numeric              ER
Timestamp       TEST(E Z)                                                      Character or Numeric              ER

D Char_Date       S              6    INZ('041596')
* INDICATOR 19 will not be set ON, since the character field is a valid MDY date without separators.
 
C     *MDY0         TEST (D)                Char_Date              19

TIME:
Time    Date_field
Time    Time-field
Time    Timestamp
Time   Numeric

EDTCDE and EDTWRD
Unexpected Results
Initialization *SYS or *JOB
Initializing date in RPG shud be in the default format or the format specified in the control specs
Move date to date – no need to specify the format
Move char to date –
Char’s date should be specified in factor 1

%DATE – Convert to date

No comments