选择 to_date(to_char(sysdate,'yyyy-mm-dd hh12:mi:ss AM'), 'yyyy-MM-dd HH12:MI:SS AM') 来自 dual;
这在 oracle 中工作正常,但在 Postgres 中不行。
最佳答案
您应该使用 current_timestamp
或 now()
而不是 sysdate
:
SELECT TO_CHAR(current_timestamp, 'yyyy-mm-dd hh12:mi:ss AM')
关于sql - 如何在 PostgreSQL 中以日期格式本身添加 AM 或 PM?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19979517/