These dates have a valid range of Januthrough December 31, 2039. Note: The exception to this is with date formats the utilize a two-digit year (*mdy, *ymd, *dmy, and *jul). Time and timestamp fields are stored in a similar (slightly more complex) manner. Depending on the date format used, the AS/400 will support dates as early as and as late as. One limitation of Excel however is that dates before are not supported. This is actually very similar to the method the AS/400 uses to store dates. The date now displayed will be January 2, 1900. Change the number to 2, and re-format the cell as a date (make sure to include year). The value displayed now will be 36525, which is the number of days from Janu– the base date used in Excel. Now, change the format of the cell to General. It will be interpreted and displayed as a date. To illustrate this, open a workbook in Microsoft Excel.
This is the same way date fields are stored in most PC applications as well. When ever the date is to be displayed, printed, written to a file, etc, an algorithm is run to convert the date from an integer to the specified format. Sometimes this format is referred to as super-julian. Therefore, if we need to allow a user to enter a date or time, we must first define a numeric or character field, test the field for a valid value, and then move that value to a date or time field.ĭate fields are stored internally (in memory) as an integer representing a number of days from a given base date. It’s one thing to be able to initialize date/time fields at compile time, but in the real world, more often than not, we need to populate date/time fields with run-time data.Īs of V4R5, display files don’t support date or time data-type fields.
If these keywords are not defined on the H-spec, the format will default to *ISO. When declaring date or time fields in an RPG program, if DATFMT or TIMFMT is not specified on the D-spec, the formats will default to the DATFMT and TIMFMT specified on the H-spec. The last 6-positions of the timestamp field are microseconds (timestamp fields are often used to generate unique keys for a file). There is only one format available for timestamp fields: The TIMFMT keyword is used in D-specs or H-specs to define the format of a time field. See IBM’s online RPG documentation for a complete description of date formats, as well as minimum and maximum values for each format. The available date formats are (note the separator characters): DATFMT Use the DATFMT keyword in D-specs or H-specs to define the format of a date field. The format determines how date and time field is displayed and printed. Note that a value of *SYS may be specified to initialize a date, time, or timestamp to the current system date/time.ĭate and time fields may be defined in a number of different formats. When defining date fields in D-specs, the INZ keyword may be used to assign an initial value to the date/time field, as in: DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++++++++++++++++++++++ Timestamp fields, which include both date and time (including micro-seconds), may also be defined. You may still have the need to write some custom date/time routines, but development of these will be greatly simplified using the new data types.ĭate and time data type fields may defined either in physical files using DDS, or as internal fields in RPG (using D-specs). With date and time fields comes a whole host of added support to validate, format, compare, and manipulate dates and times. Custom written programs then had to be developed to manipulate, validate, and interpret dates. Prior to this support, numeric fields were often used to represent date and time data. As of V3R1, the AS/400 and RPG now support date and time data types.