postgresql 日期 字符串 转换

函数
记住年月日时分秒的模式字符串:YYYY-MM-DD HH24:MI:SS

日期 --> 字符串 to_char(date, formatString)
select to_char(now(), 'YYYY-MM-DD HH24, MI:SS')

字符串 --> 日期 to_date('dateString', 'formatString')
select to_date('2021-12-18 22:24:15', 'YYYY-MM-DD HH24:MI:SS')

ref
官网链接 https://www.postgresql.org/docs/12/functions-formatting.html


已有 0 条评论

    欢迎您,新朋友,感谢参与互动!