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

标签 sql firebird firebird2.5

在 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/

相关文章:

sql - 如何在 T-SQL 中插入另一个表中的列?

MySQL查询同一列的多条数据

sql - 用联接更新表?

firebird - 通过 isql 实用程序使用十六进制二进制字符串更新 Firebird blob

php - Mysql加入而不替换原始id的值

mysql - #1452 MySQL 错误 : foreign key constraint fails

delphi - 如何在 Delphi 中实现 Firebird Blob 图像

database - Firebird 数据库 SYSDBA 连接错误

firebird - Nbackup从远程别名进行备份

sql - 如何在 Firebird 2.5 中删除列的空约束