==========================================SQL语句求日期
SELECT add_months(SYSDATE,-1) LastDay from dual;--上个月的今天
select to_char(add_months(last_day(sysdate),-1),'yyyy-MM-dd') LastDay from dual;--上个月的最后一天
select to_char(add_months(last_day(sysdate),-2)+1,'yyyy-MM-dd') FirstDay from dual;--上个月的第一天
SELECT to_char(last_day(SYSDATE)+1, 'yyyy-mm-dd') FROM dual;--下个月的第一天
SELECT TRUNC(SYSDATE, 'day')+1 BZ_KSSJ FROM dual; --本周的开始时间
SELECT TRUNC(SYSDATE, 'day')+6 BZ_JSSJ FROM dual; --本周的结束时间
SELECT to_char(SYSDATE, 'day') BZ_KSSJ FROM dual; --查看今天星期几
SELECT
CASE WHEN to_char(SYSDATE-2,'day')='星期日' THEN TRUNC(SYSDATE-3, 'day')+1
ELSE TRUNC(SYSDATE-2, 'day')+8 END BZ_KSSJ
FROM dual;
SELECT
CASE WHEN to_char(SYSDATE-2,'day')='星期日' THEN TRUNC(SYSDATE-3, 'day')-6
ELSE TRUNC(SYSDATE-2, 'day')+1 END BZ_JSSJ
FROM dual;
SELECT TRUNC(SYSDATE, 'YYYY') FROM dual;//年初
SELECT TRUNC(SYSDATE, 'MM') FROM dual;//月初
SELECT TRUNC(SYSDATE, 'DD') FROM dual;//今天
SELECT NEXT_DAY(sysdate,'星期二') FROM dual ;// 下个星期二的日期
SELECT LAST_DAY(sysdate) FROM dual ;// 表示本月的最后一天的日期