This function reads an arbitrary date time sample, and formats it according to what you require. The function takes two parameters which are the specified format strings, as follows:

  1. the first format string specifies the date time format in the sample, that is, the unformatted date time,
  2. the second format string specifies the new date time format that you require.

Some typical format strings are:

  • yyyyMMddHHmm (e.g. 200612031545)
  • dd/MM/yy (e.g. 03/12/06)
  • dd MMM yy (e.g. 01 Dec 06)
  • dd MMM yyyy, HH:mm (e.g. 01 Dec 2006, 15:45)

A typical use of this function would be to format a raw HL7 date time, and show the date and time as two calculated value attributes.

For example, given the following case fragment,

RequestDateHL7             200501011523    200506231024    200711280931

you could define the calculated values RequestDate and RequestTime to have the respective formulas

RequestDateHL7 as datetime in format “dd MMM yyyy” from format “yyyyMMddHHmm”, and

RequestDateHL7 as datetime in format “HH-mm” from format “yyyyMMddHHmm”

(Note that the “” characters are required around the format strings)

and the case would then appear as:

RequestDateHL7             200501011523    200506231024    200711280931
RequestDate                01 Jan 2005     23 Jun 2005     28 Nov 2007
RequestTime                15-23           10-24           09-31

 

Note: If the HL7 message also contains seconds, eg 20091118174700, the syntax for date and time must be modified as follows:

RequestDateHL7 as datetime in format “dd MMM yyyy” from format “yyyyMMddHHmmss”,
and

RequestDateHL7 as datetime in format “HH-mm” from format “yyyyMMddHHmmss”

For other (simpler) date and time formatting options, see as date and as time