JSON Date returned different value

Viewed 15

I am new in the JSON world and I was trying to extract the value from an object and had an issue with a date value. The weird thing is my object's property has a property and I want to get the Value in here. Date screenshot from Postgresql I am using PostgreSQL. Hoping that you could help me.

Thank you, Rome

1 Answers

Sample for you:

CREATE TABLE test4 (
    jsondata jsonb NULL
);

INSERT INTO test4 (jsondata) VALUES('{"Day": 15, "Hour": 10, "Year": 2022, "Month": 9, "Value": "2022-09-15T10:57:54"}'::jsonb);
INSERT INTO test4 (jsondata) VALUES('{"Day": 15, "Hour": 10, "Year": 2022, "Month": 9, "Value": "2022-09-15T11:22:08"}'::jsonb);

select (jsondata->>'Value')::timestamp from test4

Result: 
timestamp (this is datetime type)
2022-09-15 10:57:54.000
2022-09-15 11:22:08.000
Related