本文介绍了如何更改Postgres中的日期格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误消息

错误:日期/时间字段值超出范围: 13/01/2010
提示:也许您需要其他日期样式设置。

ERROR: date/time field value out of range: "13/01/2010"HINT: Perhaps you need a different "datestyle" setting.

我想以DD / MM / YYYY格式获取日期

I want to get my date in the format DD/MM/YYYY

推荐答案

SHOW datestyle;

 DateStyle
-----------
 ISO, MDY
(1 row)

INSERT INTO container VALUES ('13/01/2010');
ERROR:  date/time field value out of range: "13/01/2010"
HINT:  Perhaps you need a different "datestyle" setting.

SET datestyle = "ISO, DMY";
SET

INSERT INTO container VALUES ('13/01/2010');
INSERT 0 1

SET datestyle = default;
SET

最好使用明确的输入格式(ISO 8601),但是根据需要进行调整没有问题。

Of course it's best to use unambiguous input format (ISO 8601), but there is no problem to adjust it as you need.

这篇关于如何更改Postgres中的日期格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 05:41
查看更多