Formatting dates in PostgreSQL

谁说我不能喝 提交于 2019-12-19 10:32:44

问题


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

The field definition is: Ddate timestamp without time zone 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.


回答1:


You can use the to_char function to format your column:

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



回答2:


try with:

to_char(your_Field, 'dd/mm/yyyy')


来源:https://stackoverflow.com/questions/30884689/formatting-dates-in-postgresql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!