Change the date format for selected column in query

Database
Feb 17 2017
1357 Views

Change the date format for selected column in query

PostgreSQL:

to_char Function:  The PostgreSQL to_char function converts a number or date to a string.

Syntax:

to_char( value, format_mask )

Sample Query:

SELECT to_char("dDate",'.'''MM-DD-YYYY'') AS dDate FROM tablename

Applies To:

The to_char function can be used in the following versions of PostgreSQL:

PostgreSQL 9.4, PostgreSQL 9.3, PostgreSQL 9.2, PostgreSQL 9.1, PostgreSQL 9.0, PostgreSQL 8.4

Parameters or Arguments

Value: The number, date that will be converted to a string

Format_mask: The format that will be used to convert value to a string. The format_mask is different whether you are converting numbers or dates.

Leave a Reply