如何在PostgreSQL中更改日期样式? [英] How to change datestyle in PostgreSQL?

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

问题描述

在postgres中,我有一个带有日期列的表。现在postgres允许我以Y-m-d格式写日期。但是我需要d / m / Y格式的日期。怎么改变呢?

In postgres I have a table with date column. Now postgres allows me to write date in Y-m-d format. But I need date in d/m/Y format. How to change it?

我这样做时:

   show datestyle;

我得到:

 "ISO, DMY"

并以这种格式在表中输入日期 2009年2月13日

And input date in table in this format 13/02/2009

但是当我再次关闭并打开表格时,我会看到此 2009- 02-13 。 JDBC也以这种格式给我日期。我在做什么错?

But when I close and open table again I see this 2009-02-13. JDBC gives me date in this format too. What am I doing wrong?

推荐答案

yyyy-mm-dd是日期字段的推荐格式,其为ISO 8601格式。

yyyy-mm-dd is the recommended format for date field, its the ISO 8601 format.

您可以在postgresql.conf文件中更改格式。

You can change the format in the postgresql.conf file.

文档状态


用户可以使用SET
datestyle命令(PostgreSQL中的DateStyle参数)选择日期/时间样式。 conf
配置文件,或
服务器或客户端上的PGDATESTYLE环境变量。格式化函数to_char是
,它还可以作为一种更灵活的方式来格式化日期/时间输出。

The date/time styles can be selected by the user using the SET datestyle command, the DateStyle parameter in the postgresql.conf configuration file, or the PGDATESTYLE environment variable on the server or client. The formatting function to_char is also available as a more flexible way to format date/time output.

希望这会有所帮助!

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆