I need to parse the following timestamps in h2 database:
"2024-07-18T13:55:02.690632+00:00"
"2024-07-18T13:55:02.703070+00:00+00:00"
If I remove the trailing zeros after the plus sign and swap out the T with a space, it works.
parseDateTime(timestamp, 'yyyy-MM-dd HH:mm:ss.SSSSSS'))
However, I can’t figure out the correct timestamp string to parse the original formats. How do I parse them? Tried multiple formats in the parseDatetime
function, and none of them worked.
First one can be assigned to a TIMESTAMP
or TIMESTAMP WITH TIME ZONE
column directly or it can be explicitly converted with a cast (CAST(timestamp AS TIMESTAMP WITH TIME ZONE)
).
Second one is not valid at all, why it has two time zone offsets?
The mentioned function shouldn’t be used here.
In SQL, standard datetime literals look like TIMESTAMP '2024-07-18 13:55:02.690632'
, TIMESTAMP WITH TIME ZONE '2024-07-18 13:55:02.703070+00:00'
, etc. But H2 supports some additional formats, such as ISO formats with T
instead of a space.