如何在Oracle中查询每月的特定日期 [英] How to query for a specific day of the month in Oracle
问题描述
尝试自动执行查询,该查询将提取当月中的某天(在日期字段中)> = 15号的当前月份的数据.这可能吗?如果是这样,实现此目的的语法是什么?
Trying to automate a query that will pull data for the current month where the day of the month (in the date field) is >= the 15th. Is this possible? If so, what is the syntax to achieve this?
我希望每个月都可以运行此查询,而无需进行任何更改.因此,在5月,它将自动拉出日期> = 5/15/16的任何项目.在6月,它将拉出日期> = 6/15/16的项目.等等.....
I want to be able to run this query each month without having to change anything. So in May, it would automatically pull any item where the date was >= 5/15/16. In June, it would pull items where the date was >= 6/15/16. And so on.....
在此方面的任何帮助将不胜感激.谢谢
Any help in this would be greatly appreciated. Thanks
推荐答案
这将允许您使用date_field
列上的所有索引:
This will allow you to use any indexes you have on your date_field
column:
SELECT *
FROM table_name
WHERE date_field >= TRUNC( SYSDATE, 'MM' ) + INTERVAL '14' DAY
AND date_field < ADD_MONTHS( TRUNC( SYSDATE, 'MM' ), 1 );
这篇关于如何在Oracle中查询每月的特定日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!