Re: Formatting a month in query output - Mailing list pgsql-novice

From Alexander Borkowski
Subject Re: Formatting a month in query output
Date
Msg-id 41F5A99A.7050602@abri.une.edu.au
Whole thread Raw
In response to Formatting a month in query output  ("Rodolfo J. Paiz" <rpaiz@simpaticus.com>)
List pgsql-novice
Hi Rodolfo,

> I have a query which needs to provide a monthly report. Thanks to the
> date_trunc() function someone mentioned in a thread earlier today, I got
> the query working properly. However, each month is '2004-10-01 00:00:00'
> and I would like to have "October 2004".
 >
 > Which function, if any, would help me do this formatting trick? And
 > where can I read more about it?

Try to_char(the_date_you_want_to_display, 'MonthYYYY') for that. Note
that there actually is no need to use date_trunc here as to_char will
only represent only what you ask for anyway. You can find more in the
PostgreSQL Online Manual at http://www.postgresql.org/docs/manuals/
(select the one for the version you are using). The chapter is
'Functions and Operators', section 'Data Type Formatting Functions'.

HTH,

Alex

pgsql-novice by date:

Previous
From: "Sean Davis"
Date:
Subject: Re: Formatting a month in query output
Next
From: "Sean Davis"
Date:
Subject: Re: Output HTML, or just a handle?