Formatting dates in PostgreSQL

9.7k views Asked by At

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.

2

There are 2 answers

0
Mureinik On BEST ANSWER

You can use the to_char function to format your column:

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

try with:

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