Subject | Re: FB, US vs UK date formats? |
---|---|
Author | csswa |
Post date | 2002-07-12T18:06:05Z |
Insert date/time according to your requirements:
INSERT INTO TIMETEST (F_TIMESTAMP) VALUES ('13-DEC-2002');
INSERT INTO TIMETEST (F_TIMESTAMP) VALUES ('12/13/2002');
INSERT INTO TIMETEST (F_TIMESTAMP) VALUES ('13.12.2002');
The first is generic format, the second is US format, the last is
european format, but all of the above store the *same value* in the
db.
DATE/TIME and TIMESTAMP are stored in the db as 32-bit and 64-bit
integers respectively.
The first 'generic' example might be best for internationalizing your
apps (SQL-wise, that is). For getting data out in a standard way you
can CAST values as CHAR(24), which will get you a string like:
'2002-12-13 00:00:00.0000'
From there you can chunk it every which way but loose*
Or you can extract chunks via the aptly named EXTRACT function:
EXTRACT (YEAR FROM F_TIMESTAMP) year, month, day, and my favourite
being EXTRACT (BEER FROM FRIDGE).
Once again, Andrew bludgeons a simple question to death.
* © 1978 Clint Eastwood
Regards,
Andrew Ferguson
-- Am I Having Fun Yet?
INSERT INTO TIMETEST (F_TIMESTAMP) VALUES ('13-DEC-2002');
INSERT INTO TIMETEST (F_TIMESTAMP) VALUES ('12/13/2002');
INSERT INTO TIMETEST (F_TIMESTAMP) VALUES ('13.12.2002');
The first is generic format, the second is US format, the last is
european format, but all of the above store the *same value* in the
db.
DATE/TIME and TIMESTAMP are stored in the db as 32-bit and 64-bit
integers respectively.
The first 'generic' example might be best for internationalizing your
apps (SQL-wise, that is). For getting data out in a standard way you
can CAST values as CHAR(24), which will get you a string like:
'2002-12-13 00:00:00.0000'
From there you can chunk it every which way but loose*
Or you can extract chunks via the aptly named EXTRACT function:
EXTRACT (YEAR FROM F_TIMESTAMP) year, month, day, and my favourite
being EXTRACT (BEER FROM FRIDGE).
Once again, Andrew bludgeons a simple question to death.
* © 1978 Clint Eastwood
Regards,
Andrew Ferguson
-- Am I Having Fun Yet?
--- In ib-support@y..., "Jason Frey" <jason_frey@k...> wrote:
> I have a firebird database, developed on a machine with US settings.
> Problem is, when we switch the machine over to UK settings (To test
for UK
> issues, obviously) all of my queries that have dates as literal
strings are
> hosed. They need to have the date strings in US format still.
>
> For instance, take some generic person table. I want to get out
the list of
> people born on March 1st, 1990.
>
> If my machine is set to US, I need to do the following:
>
> select * from people where birthday = '03/01/1990'
>
> This works fine.
> If I switch to UK formats (after the machine reboot), I would
expect to have
> to do:
>
> select * from people where birthday = '01/03/1990'
>
> And in fact, that's the query Delphi will spit out in my code, as
all of
> it's DateToStr functions pay attention to Windows settings.
> However, I get no results. To get the same results, I'd have to do
the US
> query, even though my results that come up in my grid display in UK
format.
> Is there some setting on Interbase/Firebird (we have a mix of them,
and the
> same behavior happens on both) that needs to be set for language?
I've
> tried searching through the archives, and didn't find anything, nor
has any
> of the documentation I've looked at screamed at me "Look here for
date
> manipulation issues"
>
> Can someone elighten me as to what's going on?
>
> - Jason