select to_date(to_char(trunc(add_months(trunc(sysdate), -1), 'mm'),
'yyyy-mm-dd') || '00:00:00',
'yyyy-mm-dd hh24:mi:ss') 上月初,
to_date(to_char(last_day(add_months(trunc(sysdate), -1)),
'yyyy-mm-dd') || '23:59:59',
'yyyy-mm-dd hh24:mi:ss') 上月末,
trunc(sysdate, 'mm') 本月初,
last_day(trunc(sysdate)) 本月末 ,
to_date(to_char(trunc(add_months(trunc(sysdate), +1), 'mm'),
'yyyy-mm-dd') || '00:00:00',
'yyyy-mm-dd hh24:mi:ss') 下月初,
to_date(to_char(last_day(add_months(trunc(sysdate), +1)),
'yyyy-mm-dd') || '23:59:59',
'yyyy-mm-dd hh24:mi:ss') 下月末
from dual;
select to_date(to_char(sysdate-1, 'yyyy-mm-dd') || ' 00:00:00','yyyy-mm-dd hh24:MI:ss') 昨天初,
sysdate-1 昨天,
to_date(to_char(sysdate-1, 'yyyy-mm-dd') || ' 23:59:59','yyyy-mm-dd hh24:MI:ss') 昨天末,
to_date(to_char(sysdate, 'yyyy-mm-dd') || ' 00:00:00','yyyy-mm-dd hh24:MI:ss') 今天初,
sysdate 今天,
to_date(to_char(sysdate, 'yyyy-mm-dd') || ' 23:59:59','yyyy-mm-dd hh24:MI:ss') 今天末,
to_date(to_char(sysdate+1, 'yyyy-mm-dd') || ' 00:00:00','yyyy-mm-dd hh24:MI:ss') 明天初,
sysdate+1 明天,
to_date(to_char(sysdate+1, 'yyyy-mm-dd') || ' 23:59:59','yyyy-mm-dd hh24:MI:ss') 明天末
from dual
以上是自己总结的笔记代码了!