Re: Date Formatting

From: Richard A Lough <ralough(dot)ced(at)dnet(dot)co(dot)uk>
To: Doug Silver <dsilver(at)urchin(dot)com>
Cc: Tom Ansley <tansley(at)law(dot)du(dot)edu>, pgsql-novice(at)postgresql(dot)org
Subject: Re: Date Formatting
Date: 2002-05-06 20:39:42
Message-ID: 3CD6EA0E.55D7549D@dnet.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Doug Silver wrote:
>
> Hi Tom -
>
> select cast (now() as date) as date;
> date
> ------------
> 2002-05-03
>
> Depending on your application (e.g. perl/php script), that output is easy
> enough change it around to what you want or you could certainly write a
> function to do it -- something I have yet to do! I think such a function
> would be fairly easy to do since you're just rearranging the
> output, but doesn't everything look easy at the outset? You didn't
> mention the context of what you need this for, so there are lots of ways
> to do this.
>
> -doug
>
> On Fri, 3 May 2002, Tom Ansley wrote:
>
> > I am writing timestamps to file and the formatting is currently 2002-06-06
> > 00:00:00.0. Is there a function to only write the date and also to format it
> > something like MM/dd/yyyy ?
> >

SET DATESTYLE 'Postgres, US';

might get you part of the way there. You might need to manipulate
the output using sed/awk/Perl to get exactly what you want

To get back to the default use 'ISO' or 'European' depending on
where you started from.

HTH

Richard A Lough

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Hans Plum 2002-05-07 11:18:40 ERROR: $1 is declared CONSTANT in plpgsql
Previous Message Andrew McMillan 2002-05-06 19:59:21 Re: search and replace possible on SQL?