Subject Re: [firebird-support] Re: Date problem in Firebird
Author Martijn Tonies
> > i have a problem in select query.
> > When i issue the following select query
> >
> > "select DT_START,DT_END,DT_START || ' - ' || DT_END SHAM from
> > year_setup"
> >
> > iam getting the following result
> > dt_satrt=01.04.2005
> > dt_end=31.03.2006
> > SHAM=2005.04.01 - 2006.03.31
> >
> > (* Dates are stored in dd.mm.yyyy format in the year_setup table)
> >
> > But i want to get the third field in the same format as the first two.
> > How can i do?
>
> I can not explain why the two interpretations of the same field are
> different,

I can :-)

dt_start and dt_end are transported to the client as "date", indeed,
they are formatted by the client.

The second one is a concatenation and it transformed into a string,
which uses the server format of yyyy.mm.dd

> but generally date formatting is a client side issue. If it
> must be done in Firebird, the easiest solution I can think of at the
> moment would be to create a UDF function DateToVarChar that accepts a
> Date field and returns a varchar(10).
>
> select
> DateToVarChar(DT_START),DateToVarChar(DT_END),DateToVarChar(DT_START)
> || ' - ' || DateToVarChar(DT_END SHAM) from
> year_setup
>
> But it is normally better to do all this in the client side. I imagine
> it is more expensive (across the wire) to do this on the server side
> as well.

With regards,

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL
Server
Upscene Productions
http://www.upscene.com