Useful Oracle Queries

--Day in a week
select to_char(sysdate,'d') from dual

select to_char(sysdate,'DAY') from dual

--Day in a month
select to_char(sysdate,'fmdd') from dual

--Year
select to_char(sysdate,'yyyy') from dual

--First day of the current month
select trunc(sysdate,'mm') from dual

--First day of the current year
select trunc(sysdate,'yyyy') from dual


--first day of the previous month
select trunc(add_months(sysdate,-1),'mm') from dual

--Last day of the previous month
select trunc(sysdate,'mm')-1 from dual

No comments:

Post a Comment