Subject Re: [firebird-support] How to combine date and time?
Author Helen Borrie
At 07:41 AM 22/02/2010, you wrote:
>On Fri, Feb 19, 2010 at 4:01 AM, Ivan Prenosil <Ivan.Prenosil@...>wrote:
>
>>
>>
>> > I've legacy database where timestamp is stored in two separate
>> > fields, date and time. How I can combine the values so that I can use
>> > timestamp as a criteria?
>> >
>> > Something like this: "SELECT * FROM MY_TABLE WHERE (A_DATE + A_TIME) >
>> '2010-2-18 12:00' "
>>
>> The above is correct statement :) Do you have some problems with it ?
>>
>
>Isql gives me following error message:
>
>Statement failed, SQLCODE = -902
>Dynamic SQL Error
>-expression evaluation not supported

If A_DATE and A_TIME are strings then it's not a correct statement. The string concatenator in SQL is not '+' but double-pipe '||'.

SELECT * FROM MY_TABLE WHERE (A_DATE ||' '|| A_TIME) > '2010-2-18 12:00'

would be a valid statement in that case - but only in the sense that it is parsable. There's no guarantee you would get back what you expect, though, especially if either or both were CHAR type.

./heLen