Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use the Firebird DateAdd function in the Where clause?

In firebird can I use the DateAdd function in the 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 error;

expression evaluation not supported
like image 858
srayner Avatar asked Oct 28 '25 23:10

srayner


1 Answers

Your 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 together with the date keyword, e.g. date 'now'. So instead of current_timestamp you would need to write date'now'`.

I prefer using standard SQL functions like current_timestamp over DBMS specific ones if both are equivalent.