在PostgreSQL中格式化日期

编程入门 行业动态 更新时间:2024-10-25 15:22:58
本文介绍了在PostgreSQL中格式化日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个字段,其格式为日期和时间,例如: YYYY-MM-DD HH-MM-SS 例如: 2000- 08-12 00:00:00 我只想获取日期部分并将其格式更改为 DD / MMM / YYYY 上一个示例的结果将是: 12 / Aug / 2000

I have a field which its format is date with time as: YYYY-MM-DD HH-MM-SS for example: 2000-08-12 00:00:00 I want to get just the date part and change its format to DD/MMM/YYYY for example the expected result of the previous example will be: 12/Aug/2000

字段定义为:不带时区的Date时间戳记DEFAULT now()

我阅读了日期/时间函数和运算符以及其他来源,但我找不到任何有用的信息。

I read the whole page of Date/Time Functions and Operators and other sources as well but I couldn't find any information that is helpful.

推荐答案

您可以使用 to_char 函数设置列格式:

You can use the to_char function to format your column:

SELECT TO_CHAR(ddatte, 'dd/Mon/yyyy') FROM mytable

更多推荐

在PostgreSQL中格式化日期

本文发布于:2023-10-23 00:02:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1519132.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日期   PostgreSQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!