Oracle 获取今天和当前周开始之间的日期记录
假设我们有表错误日志,如下所示:Oracle 获取今天和当前周开始之间的日期记录,oracle,date,sysdate,Oracle,Date,Sysdate,假设我们有表错误日志,如下所示: +-------------+---------------+ | error_token | date_recorded | +-------------+---------------+ | error_1 | 05.03.2017 | +-------------+---------------+ | error_2 | 05.03.2017 | +-------------+---------------+ | error_3
+-------------+---------------+
| error_token | date_recorded |
+-------------+---------------+
| error_1 | 05.03.2017 |
+-------------+---------------+
| error_2 | 05.03.2017 |
+-------------+---------------+
| error_3 | 10.03.2017 |
+-------------+---------------+
| error_4 | 30.03.2017 |
+-------------+---------------+
获取从本周开始到今天发生的所有错误的最佳方法是什么
如果我们想得到从本月初到今天之间的所有错误,也是一样的。当你说直到今天,我假设这意味着直到但不包括今天任何小于truncsysdate的部分
见谢谢,这很有效。如果我想包括到现在为止记录的错误,那么我应该使用date\u recorder
select *
from error_log
where date_recorded >= trunc(sysdate,'W') -- beginning of week
and date_recorder < trunc(sysdate) -- optional
select *
from error_log
where date_recorded >= trunc(sysdate,'MONTH') -- beginning of month
and date_recorder < trunc(sysdate) -- optional