Siva Academy

Youtube.com/SivaAcademy  Oracle SQL  |  PLSQL  |  SQL PLSQL Interview Questions  |  PLSQL Scenario based Interview Questions  |  Subscriber Questions & Answers

  |  SQL practical Question  |  SQL Performance Tuning  |  New Features  |  

  Trigger     |    View  

Wednesday, May 15, 2019

All about Oracle Date - Part 1



Query to print all the dates of a month

with d as (
select to_date('01/01/2019','DD/MM/YYYY') as dt from dual)
select c_date,trim(to_char(c_date,'DY')) day,
       to_char(c_date,'W') week_of_month,
       to_char(c_date,'WW') week_of_year,
       to_char(c_date,'IW') iso_week_of_year
from(
select trunc(d.dt,'MONTH')+level-1 c_date
from d
connect by level <=trunc(last_day(d.dt)) -trunc(d.dt,'MONTH')+1)
order by c_date;

2 comments: