Can I use Firebird DateAdd function in Where clause?

In firebird, can I use a function DateAdd

in a where clause? I have the following sql;

select
  s.number,
  s.warranty_start
from
  serial_number s
where
  s.warranty_start > dateadd(year, -3, 'now')

      

I get an error;

expression evaluation not supported

      

+3


source to share


1 answer


The third parameter is invalid.

select
  s.number,
  s.warranty_start
from
  serial_number s
where
  s.warranty_start > dateadd(year, -3, current_timestamp)

      



'now'

is a string literal that can only be used with a keyword date

, eg. date 'now'

... So current_timestamp

you need to write date

'now' instead.

I prefer to use standard SQL functions like current_timestamp

DBMS specific if they are equivalent.

+5


source







All Articles