在 firebird 中,我可以在 where 子句中使用 DateAdd
函数吗?
我有以下 sql;
select
s.number,
s.warranty_start
from
serial_number s
where
s.warranty_start > dateadd(year, -3, 'now')
我得到错误;
expression evaluation not supported
最佳答案
您的第三个参数无效。
select
s.number,
s.warranty_start
from
serial_number s
where
s.warranty_start > dateadd(year, -3, current_timestamp)
'now'
是一个字符串文字,只能与 date
关键字一起使用,例如date 'now'
。因此,您需要编写 current_timestamp
'now'`,而不是 date
。如果两者等效,我更喜欢使用标准 SQL 函数,例如
current_timestamp
而不是 DBMS 特定函数。
关于sql - 我可以在 Where 子句中使用 Firebird DateAdd 函数吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26338233/