Subject Re: Date problem in Firebird
Author Adam
--- In firebird-support@yahoogroups.com, "shaamim_ply"
<shaamim_ply@y...> wrote:
> Hi
> 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, 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.

Hope that helps
Adam