Re: date functions

From: Jason Earl <jason(dot)earl(at)simplot(dot)com>
To: "Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: date functions
Date: 2002-02-01 16:22:57
Message-ID: 1012580578.29742.5.camel@npa01zz001
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 2002-02-01 at 06:53, Johnson, Shaunn wrote:
> Howdy:
>
> Silly question. I want to display the date from
> my table in other formats. Is this possible?
>
> For example, I have this:
>
> [example]
>
> date
> ------------
> 2000-01-07
>
> [/example]
>
> And I want this:
>
> [example]
>
> date
> ------------
> 20000107
>
> [/example]

SELECT to_char(current_date, 'YYYYMMDD');

> And maybe this:
>
>
> [example]
>
> date
> ------------
> 01/07/2001
>
> [/example]

SELECT to_char(current_date, 'DD/MM/YYYY');

> Any suggestions? Thanks!

The to_char function does precisely what you need. You can find
excellent documentation in section 4.6 of the PostgreSQL User's guide.

Jason

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Darren Ferguson 2002-02-01 16:23:32 Re: date functions
Previous Message Andrew Sullivan 2002-02-01 15:42:24 Re: Function to Pivot data