查询 'get the records from the actual month' 没有得到比当前日期大的记录
Query to 'get the records from the actual month' doesn't get me the records that have a bigger day that the current one
我有以下查询从当月table获取记录
select *
from
myTable
where
my_date BETWEEN trunc (sysdate, 'mm') AND SYSDATE;
如果记录的日期比当前记录的日期短,则此查询有效
示例:如果今天是 27/10/2016
并且我有一个包含此日期的记录:28/10/2016
日期为 28/10/2016
的记录未显示
我使用这种格式插入记录TO_DATE( '28/10/2016 18:02:44', 'dd/mm/yyyy hh24:mi:ss')
我想显示当前月份的所有记录,即使日期大于实际日期
如果您需要当月的日期
trunc(my_date, 'mm') = trunc(sysdate, 'mm')
如果您需要当月及以后的日期:
my_date >= trunc(sysdate, 'mm')
或者:
select *
from
myTable
where
my_date BETWEEN trunc (sysdate, 'mm') AND add_months(trunc (sysdate, 'mm'),1)- 1/(24*3600)
或
select *
from
myTable
where
trunc(my_date,'mm') = trunc (sysdate, 'mm')
第一个可搜索,第二个更具可读性。
我有以下查询从当月table获取记录
select *
from
myTable
where
my_date BETWEEN trunc (sysdate, 'mm') AND SYSDATE;
如果记录的日期比当前记录的日期短,则此查询有效
示例:如果今天是 27/10/2016
并且我有一个包含此日期的记录:28/10/2016
日期为 28/10/2016
的记录未显示
我使用这种格式插入记录TO_DATE( '28/10/2016 18:02:44', 'dd/mm/yyyy hh24:mi:ss')
我想显示当前月份的所有记录,即使日期大于实际日期
如果您需要当月的日期
trunc(my_date, 'mm') = trunc(sysdate, 'mm')
如果您需要当月及以后的日期:
my_date >= trunc(sysdate, 'mm')
或者:
select *
from
myTable
where
my_date BETWEEN trunc (sysdate, 'mm') AND add_months(trunc (sysdate, 'mm'),1)- 1/(24*3600)
或
select *
from
myTable
where
trunc(my_date,'mm') = trunc (sysdate, 'mm')
第一个可搜索,第二个更具可读性。