I was converting the timestamp to date in the RPGLE program and was getting the run time error Date, Time or Timestamp value is not valid (C G D F)
.
Additional Message Information
Message ID . . . . . . : RNQ0112 Severity . . . . . . . : 99
Message type . . . . . : Inquiry
Date sent . . . . . . : 09/02/24 Time sent . . . . . . : 09:03:48
Message . . . . : Date, Time or Timestamp value is not valid (C G D F).
Cause . . . . . : RPG procedure TESTDATE in program TESTLIB/TESTDATE, at
statement 4 referenced a Date, Time or Timestamp variable which contained a
value which is not valid. Some examples of values which are not valid are:
-- A date of 1994/02/31, which is not possible.
-- A time of 01/03:04, which does not have correct separators.
Recovery . . . : Contact the person responsible for program maintenance to
determine the cause of the problem.
Possible choices for replying to message . . . . . . . . . . . . . . . :
D -- Obtain RPG formatted dump.
S -- Obtain system dump.
F -- Obtain full formatted dump.
Application error. RNX0112 unmonitored by TESTDATE at statement 0000000004,
This is the dump that I have taken,
ILE RPG FORMATTED DUMP
Program Status Area:
Procedure Name . . . . . . . . . . . . : TESTDATE
Program Name . . . . . . . . . . . . . : TESTDATE
Library . . . . . . . . . . . . . . : TESTLIB
Module Name. . . . . . . . . . . . . . : TESTDATE
Program Status . . . . . . . . . . . . : 00112
Date, Time or Timestamp value is not valid (C G D F).
Previous Status . . . . . . . . . . . : 00000
Statement in Error . . . . . . . . . . : 00000004
RPG Routine . . . . . . . . . . . . . : *DETC
Number of Parameters . . . . . . . . . :
Message Type . . . . . . . . . . . . . : RNX
Additional Message Info . . . . . . . : 0112
Message Data . . . . . . . . . . . . . :
Date, Time or Timestamp value is not valid.
Status that caused RNX9001 . . . . . . :
Last File Used . . . . . . . . . . . . :
Last File Status . . . . . . . . . . . :
Last File Operation . . . . . . . . . :
Last File Routine . . . . . . . . . . :
Last File Statement . . . . . . . . . :
Last File Record Name . . . . . . . . :
Job Name . . . . . . . . . . . . . . . : QPAD082410
User Name . . . . . . . . . . . . . . : ADMIN
Job Number . . . . . . . . . . . . . . : 204501
Date Entered System . . . . . . . . . : 09022024
Century . . . . . . . . . . . . . . : 20
Date Started . . . . . . . . . . . . . : *N/A*
Time Started . . . . . . . . . . . . . : *N/A*
Compile Date . . . . . . . . . . . . . : 090224
Compile Time . . . . . . . . . . . . . : 090652
Compiler Level . . . . . . . . . . . . : 0001
Source File . . . . . . . . . . . . . : QNA
Library . . . . . . . . . . . . . . : TESTLIB
Member . . . . . . . . . . . . . . . . : TESTDATE
ILE RPG FORMATTED DUMP
Module Name. . . . . . . . . . . . . . : TESTDATE
Optimization Level . . . . . . . . . . : *NONE
Halt Indicators:
H1 '0' H2 '0' H3 '0' H4 '0' H5 '0' H6 '0' H7 '0' H8 '0' H9 '0'
Command/Function Key Indicators:
KA '0' KB '0' KC '0' KD '0' KE '0' KF '0' KG '0' KH '0' KI '0' KJ '0'
KK '0' KL '0' KM '0' KN '0' KP '0' KQ '0' KR '0' KS '0' KT '0' KU '0'
KV '0' KW '0' KX '0' KY '0'
Control Level Indicators:
L1 '0' L2 '0' L3 '0' L4 '0' L5 '0' L6 '0' L7 '0' L8 '0' L9 '0'
Overflow Indicators:
OA '0' OB '0' OC '0' OD '0' OE '0' OF '0' OG '0' OV '0'
External Indicators:
U1 '0' U2 '0' U3 '0' U4 '0' U5 '0' U6 '0' U7 '0' U8 '0'
General Indicators:
01 '0' 02 '0' 03 '0' 04 '0' 05 '0' 06 '0' 07 '0' 08 '0' 09 '0' 10 '0'
11 '0' 12 '0' 13 '0' 14 '0' 15 '0' 16 '0' 17 '0' 18 '0' 19 '0' 20 '0'
21 '0' 22 '0' 23 '0' 24 '0' 25 '0' 26 '0' 27 '0' 28 '0' 29 '0' 30 '0'
31 '0' 32 '0' 33 '0' 34 '0' 35 '0' 36 '0' 37 '0' 38 '0' 39 '0' 40 '0'
41 '0' 42 '0' 43 '0' 44 '0' 45 '0' 46 '0' 47 '0' 48 '0' 49 '0' 50 '0'
51 '0' 52 '0' 53 '0' 54 '0' 55 '0' 56 '0' 57 '0' 58 '0' 59 '0' 60 '0'
61 '0' 62 '0' 63 '0' 64 '0' 65 '0' 66 '0' 67 '0' 68 '0' 69 '0' 70 '0'
71 '0' 72 '0' 73 '0' 74 '0' 75 '0' 76 '0' 77 '0' 78 '0' 79 '0' 80 '0'
81 '0' 82 '0' 83 '0' 84 '0' 85 '0' 86 '0' 87 '0' 88 '0' 89 '0' 90 '0'
91 '0' 92 '0' 93 '0' 94 '0' 95 '0' 96 '0' 97 '0' 98 '0' 99 '0'
Internal Indicators:
LR '0' MR '0' RT '0' 1P '0'
NAME ATTRIBUTES VALUE
DATE1 DATE(10) '0001-01-01' 'F0F0F0F160F0F160F0F1'X
TIMESTAMP1 TIMESTAMP(26) '0001-01-01-00.00.00.000000'
VALUE IN HEX 'F0F0F0F160F0F160F0F160F0F04BF0F04BF0F04BF0F0F0F0F0F0'X
* * * * * E N D O F R P G D U M P * * * * *
The source code is
Dtimestamp1 s Z
Ddate1 s D
/free
date1 = %date('2024-03-16-15.10.40.456465');
return;
/end-free
Line 1: I declared a timestamp variable timestamp1
.
Line 2: Declared a date variable date1
.
Line 3 & 6: /free
and /end-free
block to write rpg-free code.
Line 4: Passing the timestamp value in character format to %date
built-in function and evaluating the result date in the date1
variable.
Line 5: return from the RPG program.
what I am doing wrong here date1 = %date(‘2024-03-16-15.10.40.456465’);
for which I am getting an invalid timestamp value error
.
In this case, you are passing the timestamp value in character format to the
%date
built-in function which is incorrect. Try converting the timestamp value in character format to timestamp type and then pass it to the%date
bif as a parameter that will work.This is the correct RPGLE source code converting timestamp to date and now you won’t encounter the error
Date, Time or Timestamp value is not valid (C G D F)
.Line 3: Converting the
‘2024-03-16-15.10.40.456465'
timestamp value in character type to timestamp type by using%timestamp
bif i.e.%timestamp(‘2024-03-16-15.10.40.456465')
and then pass this value to the%date
bif as%date(%timestamp(‘2024-03-16-15.10.40.456465'))
. This will return the date as‘2024-03-16’
out of the timestamp value in thedate1
variable.