Subject Re: [firebird-support] UNIX_TIMESTAMP to What for FB15
Author Helen Borrie
Lee,

At 08:25 PM 24/05/2004 +0000, you wrote:
>I searched this site for UNIX_TIMESTAMP and other places in order to
>know how to deal with this in FB15. I'm converting a MySQL system and
>this is in a query that is blowing up on me. Here's the query and if
>anyone has any ideas on how do deal with this, I would love to hear
>your comments.
>
>$Query = "SELECT ID, Headline, Summary, Body, Location, " .
>"UNIX_TIMESTAMP(Expires) AS Expires, DisplayPrecedence " .
>"FROM news " .
>"WHERE expires > 'NOW()' ";

Firebird uses standard SQL and doesn't support platform-specific
formats. Find out what the UNIX_TIMESTAMP format represents and use CAST
if necessary. The date literal 'NOW' is supported, but deprecated, and
needs to be cast to a TIMESTAMP type in Firebird for comparisons. You
would do better to replace it with the standard SQL context variable
CURRENT_TIMESTAMP.

If your EXPIRES column is already a TIMESTAMP type, simply remove the MySQL
function call. If it is a DATE type, then use
WHERE CAST(Expires as TIMESTAMP) > CURRENT_TIMESTAMP. The CAST will
convert the DATE to a TIMESTAMP with a time part of '00:00:00.0000'. If
you are only wanting to compare a DATE with a DATE, then replace the WHERE
clause with
WHERE Expires > CURRENT_DATE.

/heLen