I have a string field in a table whose value is date format like: 2020-12-08T18:06:55.132Z or 2020-12-08T18:06:55.132+11:00.
How can I search this field based on date? Like select * from my_table where timestamp > '2020-12-08T00:00:00'.
I have a string field in a table whose value is date format like: 2020-12-08T18:06:55.132Z or 2020-12-08T18:06:55.132+11:00.
How can I search this field based on date? Like select * from my_table where timestamp > '2020-12-08T00:00:00'.
You can try something like:
SELECT *
FROM my_table
WHERE to_timestamp(timestamp,'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"') > '2020-12-08T00:00:00'
EDIT:
Something even easier, which doesn't rely on your timestamp format:
SELECT *
FROM my_table
WHERE timestamp::timestamp > '2020-12-08T00:00:00'
ERROR: value for "YYYY" in source string is out of range DETAIL: Value must be in the range -2147483648 to 2147483647.'2020-12-08T18:06:55.132Z' instead of timestamp, it works)