%TIMESTAMP Built-In Functions in rpgle
%TIMESTAMP function is used to convert string into timestamp data type.
Format of this function is %TIMESTAMP (value : *ISO | *ISO0 )
Here 1st paramter is the Input value which we want to convert to timestamp.
We can mention 2nd parameter as well, which tells us about timestamp format of input string.
Example –%timestamp built-in function in rpgle
Columns . . . : 6 80 AMIT/QRPGSRC
SEU==> TESTRPG
FMT * *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8
*************** Beginning of data *****************************************
0001.00 D times s Z
0002.00 D InputCharISO S 30A
0003.00 D InputCharISO0 S 30A
0004.00
0005.00 C* %Timestamp() without any parameter
0006.00 C EVAL times = %TIMESTAMP()
0007.00 C times DSPLY
0008.00 C
0009.00 C* Input string in *iso format
0010.00 C EVAL InputCharISO = '2017-10-05-12.34.56.120110'
0011.00 C EVAL times = %TIMESTAMP(InputCharISO)
0012.00 C times DSPLY
0013.00 C
0014.00 C* Input string in *iso format + *ISO Input format
0015.00 C EVAL InputCharISO = '2017-10-05-12.34.56.120110'
0016.00 C EVAL times = %TIMESTAMP(InputCharISO:*ISO)
0017.00 C times DSPLY
0018.00 C
0019.00 C* Input string in *iso0 format + *ISO0 Input format
0020.00 C EVAL InputCharISO0 = '20171005123456120110'
0021.00 C EVAL times = %TIMESTAMP(InputCharISO0:*ISO0)
0022.00 C times DSPLY
0023.00 C
0024.00
0025.00 C Seton LR
Output
DSPLY 2017-11-20-17.29.53.893000
DSPLY 2017-10-05-12.34.56.120110
DSPLY 2017-10-05-12.34.56.120110
DSPLY 2017-10-05-12.34.56.120110