Bhavbhuti Nathwani wrote:

I am using the following (partial) code to get a string of a date from a datetime field

' dtd. ' || CAST (EXTRACT(DAY from tPS.tDt) AS CHAR(2)) || '/'
 || CAST (EXTRACT(MONTH from tPS.tDt) AS CHAR(2))
 || '/' || CAST (EXTRACT(YEAR from tPS.tDt) AS CHAR(4))

Is there a better way to do this?

Dimitry Sibiryakov answers:

Definitely, cast(dtd as varchar(20)) is much better.

Bhavbhuti Nathwani adds:

I tried your suggestion, more like:

' dtd. ' || CAST(CAST(tPS.tDt AS DATE) AS VARCHAR(20))

for obvious reason, that is fine and it works as promised.

Now my issue is that the date come up as 2009-06-09, that is a bit of a problem from a users perspective as they would like to have it in the local 09/06/2009 (or 09-06-2009) format

Is this possible?

Dimitry Sibiryakov answers:

If users want date in local format, they must format the date on local computer. I easily can imagine two users with different regional settings, so they would like to have the same data in different format. It is not server's job to format data.

Milan Babuskov answers:

It would be best retrieve dates as dates and create a string representation on the client side, in your application. But, if you really need to, there are various options listed here:

http://www.firebirdfaq.org/faq314

Like this post? Share on: TwitterFacebookEmail


Related Articles


Author

Firebird Community

Published

Category

Gems from Firebird Support list

Tags