SQL 如何在H2数据库SQL查询中使用当前日期

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14773729/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 13:34:12  来源:igfitidea点击:

How to use current date in H2 database SQL query

sqlh2

提问by Pavel Vyazankin

I need something like

我需要类似的东西

select * from tableName where date_column > now()

However, now()doesn't work in H2. Please advise.

但是,now()在 H2 中不起作用。请指教。

回答by John Woo

use CURRENT_TIMESTAMP

CURRENT_TIMESTAMP

select * from tableName where date_column > CURRENT_TIMESTAMP()

回答by Pavel Vyazankin

IF you want to compare with present date only then use

如果您只想与当前日期进行比较,请使用

select * from tableName where date_column > CURRENT_DATE()

IF you want to compare with present date and time also

如果您还想与当前日期和时间进行比较

select * from tableName where date_column > CURRENT_TIMESTAMP