Subject Re: [firebird-support] date function
Author Bisma Jayadi
Thanks Helen... but the problem still persist...

> CURRENT_DATE
>
> insert into aTable (aDate)
> values (CURRENT_DATE)

This works fine.

> and
> SELECT CURRENT_DATE FROM RDB$DATABASE

But, this doesn't. "Field name missing" error arise.

> UPDATE aTable
> set blah = CURRENT_DATE + 1
>
> DELETE from aTable
> where date between CURRENT_DATE - 30 and CURRENT_DATE - 15

This works fine too.

> Operating with months isn't so simple - work out what you want and use
> either an expression or a UDF.

Alright then. I know it's not so simple, but database engine should help rather
than giving it up to the users. That's what computer is all about, right? :) I
hope the next minor version release (1.6?) will support DB2's date/time style
syntax. Believe me, it'll help us a lot. :)

> SELECT CURRENT_DATE, FIELD_NAME FROM ATABLE

This doesn't work, same error as above.

> See also CURRENT_TIMESTAMP (to include time) and the predefined date
> literals 'TODAY', 'TOMORROW', 'YESTERDAY' and 'NOW'. PDDLs have to be cast.
>
> So, these are the same:
>
> SELECT CURRENT_DATE + 1 FROM RDB$DATABASE

This doesn't work.

> and
> SELECT CAST('TOMORROW' AS DATE) FROM RDB$DATABASE

This works.

I don't know why some of the syntaxes above raise an error. FYI, I use Firebird
1.5 on WindowsXP SP1 using dbExpress (Delphi 7). I believe the problem isn't
with the OS or the client application since other queries work fine.

It seems that predefined date literals are considered just like ordinary
internal database variables/constants, not as special identifiers that the
database would automagically understand what the user want from its position in
the query.

Oh, one more question... it seems that default udf (ib_udf and fbudf) is not
automatically included in the database. Am I right? Or did I do something wrong
in the installation? Because, I can't use ABS() without registering the udf.

For any kind of help, I thank you all in advanced.

-Bee-

has Bee.ography at:
http://beeography.modblog.com