Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formatting dates in PostgreSQL

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.

like image 432
John Avatar asked May 15 '26 03:05

John


2 Answers

You can use the to_char function to format your column:

SELECT TO_CHAR(ddatte, 'dd/Mon/yyyy') FROM mytable
like image 51
Mureinik Avatar answered May 16 '26 20:05

Mureinik


try with:

to_char(your_Field, 'dd/mm/yyyy')
like image 39
jurhas Avatar answered May 16 '26 21:05

jurhas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!