How to convert 'dd-mm-yyyy' to 'dd-mmm-yyyy' in postgresql?

Member

by domenico , in category: MySQL , 4 months ago

How to convert 'dd-mm-yyyy' to 'dd-mmm-yyyy' in postgresql?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by haylee.mertz , 4 months ago

@domenico 

You can convert the date format from 'dd-mm-yyyy' to 'dd-mmm-yyyy' in PostgreSQL using the to_char() function. Here's an example query to achieve this:

1
2
SELECT to_char(your_date_column::date, 'DD-Mon-YYYY') AS new_date_format
FROM your_table_name;


Replace your_date_column with the column name containing the date value and your_table_name with your actual table name.


In the to_char() function, 'Mon' represents the abbreviated month name (e.g. Jan, Feb, Mar). You can also use 'Month' for the full month name (e.g. January, February, March).