[英]How to update the date format in postgres?
I have dates in the database with the format YYYYMMDD. 我数据库中的日期格式为YYYYMMDD。 But i would like to update them all to MM/DD/YYYYY. 但我想将它们全部更新为MM / DD / YYYYY。
How do i do that? 我怎么做?
There is no format stored in the date/time data types. 日期/时间数据类型中没有存储格式。 If you want an specific output format use the to_char function 如果要特定的输出格式,请使用to_char函数
select to_char(current_date, 'MM/DD/YYYY');
If the date column is text then first cast it to date to use the above function 如果日期列是文本,则首先将其转换为日期以使用上述功能
select to_char(start_date::date, 'MM/DD/YYYY');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.