MONTHS_BETWEEN: gives number of months between two dates
ADD_MONTHS: adds calendar months to date
NEXT_DAY: gives next day of the date specified
LAST_DAY: gives last day of the month
ROUND: round date
TRUNC: truncate date
SELECT
months_between(TO_DATE('2017-05-01','yyyy-mm-dd'),TO_DATE('2017-01-25','yyyy-mm-dd') ) months
FROM
dual;
SELECT
SYSDATE,
add_months(SYSDATE,2)
FROM
dual;
select sysdate, round(sysdate,'MONTH') round_mon from dual;
select sysdate, round(sysdate,'YEAR') round_yr from dual;
ADD_MONTHS: adds calendar months to date
NEXT_DAY: gives next day of the date specified
LAST_DAY: gives last day of the month
ROUND: round date
TRUNC: truncate date
SELECT
months_between(TO_DATE('2017-05-01','yyyy-mm-dd'),TO_DATE('2017-01-25','yyyy-mm-dd') ) months
FROM
dual;
SELECT
SYSDATE,
add_months(SYSDATE,2)
FROM
dual;
select sysdate, next_day(sysdate,'MONDAY') next_monday from dual;
select to_char(sysdate,'DD-MON-YY') now, last_day(sysdate) last_day_of_month from dual;
select sysdate, round(sysdate,'MONTH') round_mon from dual;
select sysdate, round(sysdate,'YEAR') round_yr from dual;
No comments:
Post a Comment