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

你离开我真会死。 提交于 2020-01-04 05:33:10

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/26338233/can-i-use-the-firebird-dateadd-function-in-the-where-clause

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!