I need to search all columns in postgre sql table using a string.But it causes error for column with type "timestamp without timezone"; It shows the error:"ERROR: operator does not exist: timestamp without time zone ~~ unknown"
You are trying to search a timestamp
using the LIKE
operator (internally ~~
). That cannot work, because that operator does not exist for datetime data types.
You will have to cast the timestamp
to a string data type:
WHERE CAST(timestamp_col AS text) LIKE '2021-%'
or, better, explicitly format it as string:
WHERE to_char(timestamp_col, 'YYYY-MM-DD HH24:MI:SS') LIKE '2021-%'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.