Thread: converting to german date format

converting to german date format

From
Janning Vygen
Date:
Hi,

i have different databases with have columns of type 'date'.
my application converts the date format to german date format like
09-28-2001 to 28.09.2001 and back again if the user enters a german
date format.

are there any solutions to do stuff like this inside the database?
i am thinking of two solutions:
a) a trigger which is fired on each select and insert/update to
convert german date format to postgres date format.
b) create a new type which has input and output routines to convert
them and inherits date format

quite new to sql i need some advice of what is the best solution and
if there is any open source out there i can use?

janning

--
Planwerk 6 /websolutions
Herzogstraße 86
40215 Düsseldorf

fon 0211-6015919
fax 0211-6015917
http://www.planwerk6.de

Re: converting to german date format

From
Thomas Lockhart
Date:
> i have different databases with have columns of type 'date'.
> my application converts the date format to german date format like
> 09-28-2001 to 28.09.2001 and back again if the user enters a german
> date format.
> are there any solutions to do stuff like this inside the database?

Of course :)

thomas=# set datestyle = 'german';
SET VARIABLE

thomas=# select date 'now';
    date
------------
 29.09.2001
(1 row)

hth

                         - Thomas

Re: converting to german date format

From
Janning Vygen
Date:
Am Samstag, 29. September 2001 09:52 schrieb Thomas Lockhart:
> > i have different databases with have columns of type 'date'.
> > my application converts the date format to german date format
> > like 09-28-2001 to 28.09.2001 and back again if the user enters a
> > german date format.
> > are there any solutions to do stuff like this inside the
> > database?
>
> Of course :)
>
> thomas=# set datestyle = 'german';
> SET VARIABLE
>
> thomas=# select date 'now';
>     date
> ------------
>  29.09.2001
> (1 row)

it's easier than i expected. Thanks a lot!

janning