Q:

How change format date in postgresql

I have a PostgreSQL query:
SELECT "message" FROM "mytable" 
WHERE "start_date" <= current_date AND "end_date" >= current_date

The current_date is the date of the system, for example today current system is: 29-08-2019
the type of all the fields are String.
the format of the current_date is "YYYY-DD-MM", and the format of the start_date and end_date are "DD-MM-YYYY"
How can I change the format of current_date to "DD-MM-YYYY" using postgresql or javascript ?
thank you

A:

Postgres
You can use any of the methods listed under "Data Type Formatting Functions" section of the docs. For comparisons, either use to_date() or to_timestamp() functions.
Javascript
There isn't a direct method on the Date class but you use a snippet for this.
const datetime = new Date()
const date = datetime.toISOString().split('T')[0]
const formattedDate = date.split('-').reverse().join('-')

