从日期字段中提取月份 [英] Extract Month From Date Field
本文介绍了从日期字段中提取月份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Postgresql数据库中有一个日期字段(输入字段名称),我如何仅从日期字段中提取月份?我使用了以下语法,但我希望它显示实际的月份名称,而不是月份的数字
I have a date field in a postgresql database (field name is input) how can I extract the month only from the date field? I used the syntax below, but I want it to show the actual month name, not a numeric value for the month
EXTRACT(MONTH FROM input) AS "Month"
因此,如果字段输入中的日期为04/26 / 2016此语法返回4,如何更改此格式以返回April
So if the date in the field input was 04/26/2016 this syntax returns 4, how could I alter this to return April
推荐答案
您可能会发现此有用
SELECT to_char(to_timestamp(date_part('month',timestamp'2016-04-26 20:38:40'):: text,'MM'),'月')
一切顺利
引用 Postgresql(当前)第9.9节。日期/时间函数和运算符
这篇关于从日期字段中提取月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文