%TIMESTAMP (Convert to Timestamp)

%TIMESTAMP{(char-num-expression { : *ISO|*ISO0 : {fractional-seconds}})}
%TIMESTAMP{(date-timestamp-expression { : fractional-seconds})}

Start of changeIf you do not specify a parameter, or if you specify *SYS as the first parameter, %TIMESTAMP returns the current system timestamp.End of change

Start of change%TIMESTAMP converts the value of the expression from character, numeric, date or timestamp data to type timestamp. The converted value is returned as a timestamp.End of change

Start of changeThe first parameter is the value to be converted. If you do not specify a value, %TIMESTAMP returns the current system timestamp. Only the first three digits of the fractional seconds portion of the timestamp will be set to a non-zero value. The remaining fractional seconds will be zero.End of change

Start of changeThe number of fractional seconds can be between 0 and 12. It defaults to 6 fractional seconds.End of change

For more information, see Information Operations or Built-in Functions.

Figure 1. %TIMESTAMP Example
 *..1....+....2....+....3....+....4....+....5....+....6....+....7...+....

   string = '1960-09-29-12.34.56.000000';
   timest =  %timestamp(string);
    // timest now contains z'1960-09-29-12.34.56.000000'

   date = '2001-03-05';
   timest =  %timestamp(date);
    // timest now contains z'2001-03-05-00.00.00.000000'

   dsply (%timestamp(*SYS));
    // It displays 2014-06-27-01.02.03.421000

   dsply (%timestamp(*SYS : 1));
    // It displays 2014-06-27-01.02.03.4

   dsply (%timestamp(*SYS : 0));
    // It displays 2014-06-27-01.02.03