Re: Date Formatting - Mailing list pgsql-novice

From Richard A Lough
Subject Re: Date Formatting
Date
Msg-id 3CD6EA0E.55D7549D@dnet.co.uk
Whole thread Raw
In response to Re: Date Formatting  (Doug Silver <dsilver@urchin.com>)
Responses Time Formatting  (hodges@xprt.net)
List 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

pgsql-novice by date:

Previous
From: Andrew McMillan
Date:
Subject: Re: search and replace possible on SQL?
Next
From: Wendy Powley
Date:
Subject: Stored Procedures