Thread: format date retrieved from database

format date retrieved from database

From
Naomi Fullam
Date:
Hi
I found this function for mysql

SELECT DATE_FORMAT(myDateField, '%d-%m-%Y') FROM myTable

The DATE_FORMAT function allows one to format myDateField as I see fit,
I want to have it in date-month-year format. myDateField is of type
date.

Basically I was just wondering if there is a similar Postgres command?

Thanks in advance!

Naomi

Re: format date retrieved from database

From
Michael Fork
Date:
You want to take a look at the to_char function described here:

http://www.postgresql.org/devel-corner/docs/user/functions-formatting.html

in your case it would be:

SELECT to_char(myDateField, 'DD-MM-YYYY')

Michael Fork - CCNA - MCP - A+
Network Support - Toledo Internet Access - Toledo Ohio

On Fri, 23 Mar 2001, Naomi Fullam wrote:

> Hi
> I found this function for mysql
>
> SELECT DATE_FORMAT(myDateField, '%d-%m-%Y') FROM myTable
>
> The DATE_FORMAT function allows one to format myDateField as I see fit,
> I want to have it in date-month-year format. myDateField is of type
> date.
>
> Basically I was just wondering if there is a similar Postgres command?
>
> Thanks in advance!
>
> Naomi
>


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)




Re: format date retrieved from database

From
Michael Fork
Date:
You want to take a look at the to_char function described here:

http://www.postgresql.org/devel-corner/docs/user/functions-formatting.html

in your case it would be:

SELECT to_char(myDateField, 'DD-MM-YYYY')

Michael Fork - CCNA - MCP - A+
Network Support - Toledo Internet Access - Toledo Ohio

On Fri, 23 Mar 2001, Naomi Fullam wrote:

> Hi
> I found this function for mysql
>
> SELECT DATE_FORMAT(myDateField, '%d-%m-%Y') FROM myTable
>
> The DATE_FORMAT function allows one to format myDateField as I see fit,
> I want to have it in date-month-year format. myDateField is of type
> date.
>
> Basically I was just wondering if there is a similar Postgres command?
>
> Thanks in advance!
>
> Naomi
>


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)