RXS_charToTimestamp()

Use RXS_charToTimestamp() to easily convert a timestamp coming from an XML document (i.e. string representation of a timestamp) to a valid IBM i/RPG timestamp format. This will save the headache of programming for all of the different timestamp formats out there and doing a bunch of sub-stringing and concatenation.

Valid keywords for pFormat are listed below:

  • yyyy = Year
  • MM = Month
  • dd = Day
  • hh = Hour
  • mm = Minute
  • ss = Second
  • SS = Millisecond

Typical usage would look like:

RXS_charToTimestamp(strTimestamp: 'yyyy-MM-dd-hh.mm.ss.SSSSSS': %Timestamp());

Subprocedure Prototype

D RXS_charToTimestamp...
D                 pr              z

Converts a character string to a timestamp value.

D  pString                      30a   value

Required

Character string date/time data which is to be converted to a timestamp.

Example: 2016-04-21-13.12.24

D  pFormat                      30a   value

Required

The format of the date/time character string.

Example: yyyy-MM-dd-hh.mm.ss

D  pDft                           z   value

Required

Default, fallback return value that will be returned if the subprocedure cannot process the character string passed in the first parameter.

Example: %timestamp()