Subject Re: [IBO] IB_SQL and dates
Author Helen Borrie (TeamIBO)
At 11:41 AM 24-06-02 +0100, you wrote:
>Would I be correct in saying that when I use IB_SQL to do an insert (on the
>DSQL or SCRIPT tabs) where some of the fields are datatype DATE, that I must
>always insert in the USA format of mm/dd/yyyy as in :
>
>insert into test_table (a_date_field) values (cast ('12/31/2002' as date));
>
>or is there a way to do it in the client's chosen date format ?

Well, in IB you can't supply a date-decoding template, but IB has a number
of date literal formats that prescribe the decoding.

The following are recognised (square brackets not part of the literal -
they just indicate optional bits) :

mm/dd/[cc]yy
dd.mm.[cc]yy
[d]d-MMM-[cc]yy (where MMM is JAN, FEB, MAR, etc., regardless of your local
language)
ccyy-mm-dd
ccyymmdd


>In oracle (Sorry) I can do this :
>
>insert into test_table (a_date_field) values
>(to_date('31/12/2002','DD/MM/YYYY'));

In IB you would do:
insert into test_table (a_date_field) values (cast ('31.12.2002' as date));
or
insert into test_table (a_date_field) values (cast ('31-DEC-2002' as date));

>I've looked in the docs, but can't find anything (which doesn't mean it
>isn't there ...).

It's not an IBO-thang, it's an IB-implementation-thang. Read up the
Firebird or InterBase manuals, on date and time datatypes. The fun part in
Borland IDE's (and IBO, by inheritance) comes in trying to persuade their
language parsers to accept non-US date formats in methods like StrToDate
and AsDate.

In IB_SQL, you can use the appropriate date literal in DSQL but not in the
data-entry forms. It's a wart I will fix one day if someone else doesn't
get there first and do it.


>PC local settings English(UK) and date format is dd/mm/yyyy.

Local settings are a Microsoft-thang and don't count in
platform-independent SQL. Microsoft-only databases/drivers sometimes
implement them.

regards,
Helen Borrie (TeamIBO Support)

** Please don't email your support questions privately **
Ask on the list and everyone benefits
Don't forget the IB Objects online FAQ - link from any page at
www.ibobjects.com