我可以在Where子句中使用Firebird DateAdd函数吗?

sra*_*ner 3 sql firebird firebird2.5

在firebird中我可以DateAdd在where子句中使用该函数吗?我有以下sql;

select
  s.number,
  s.warranty_start
from
  serial_number s
where
  s.warranty_start > dateadd(year, -3, 'now')
Run Code Online (Sandbox Code Playgroud)

我得到错误;

expression evaluation not supported
Run Code Online (Sandbox Code Playgroud)

a_h*_*ame 6

您的第三个参数无效.

select
  s.number,
  s.warranty_start
from
  serial_number s
where
  s.warranty_start > dateadd(year, -3, current_timestamp)
Run Code Online (Sandbox Code Playgroud)

'now'是一个字符串文字,只能与date关键字一起使用,例如date 'now'.所以current_timestamp你不需要写date'现在'.

current_timestamp如果两者都是等价的,我更喜欢使用标准的SQL函数,例如DBMS特定的函数.