Oracle Data/Time Functions
SELECT
to_char(to_date ('20-AUG-1988'), 'RRRR') calendar_year
,to_char(to_date ('20-AUG-1988'), 'WW') week_of_year
,to_char(to_date ('20-AUG-1988'), 'Q') quarter_of_year
,to_char(to_date ('20-AUG-1988'), 'MM') month_of_year
,to_char(to_date ('20-AUG-1988'), 'W') week_of_month
,to_char(to_date ('20-AUG-1988'), 'D') day_of_the_week
,to_char(to_date ('20-AUG-1988'), 'DAY') name_of_the_day
FROM DUAL;
SELECT
add_months (sysdate, 12) add_months
,current_date system_date
,current_timestamp system_timestamp
,dbtimezone timezone
,extract (year from sysdate) extract_year
,extract (month from sysdate) extract_month
,extract (day from sysdate) extract_date
,last_day (sysdate) month_last_day
,months_between (sysdate, '20-aug-1988') months_between
,new_time(sysdate, 'PST', 'AST') newtime
,next_day(sysdate, 'SUNDAY') next_weekday
,round (to_date (sysdate),'YEAR') rounding_year
,round (to_date (sysdate),'Q') rounding_quarter
,round (to_date (sysdate),'MONTH') rounding_month
,sysdate sys_date
,systimestamp sys_timestamp
,trunc (sysdate) trunc_time
FROM DUAL;
SELECT least('01-jan-2016','01-jan-2017') least_date
,greatest ('01-jan-2016','31-dec-2015') greatest_date
, sign (to_date('01-jan-2016') - to_date('01-jan-2017')) date_sign_ex1
, sign (to_date('01-jan-2020') - to_date('01-jan-2017')) date_sign_ex2
, sign (to_date('01-jan-2019') - to_date('31-dec-2017')) date_sign_ex2
, to_date('01-jan-2016') - to_date('01-jan-2017') subtract_dates
FROM DUAL;
to_char(to_date ('20-AUG-1988'), 'RRRR') calendar_year
,to_char(to_date ('20-AUG-1988'), 'WW') week_of_year
,to_char(to_date ('20-AUG-1988'), 'Q') quarter_of_year
,to_char(to_date ('20-AUG-1988'), 'MM') month_of_year
,to_char(to_date ('20-AUG-1988'), 'W') week_of_month
,to_char(to_date ('20-AUG-1988'), 'D') day_of_the_week
,to_char(to_date ('20-AUG-1988'), 'DAY') name_of_the_day
FROM DUAL;
SELECT
add_months (sysdate, 12) add_months
,current_date system_date
,current_timestamp system_timestamp
,dbtimezone timezone
,extract (year from sysdate) extract_year
,extract (month from sysdate) extract_month
,extract (day from sysdate) extract_date
,last_day (sysdate) month_last_day
,months_between (sysdate, '20-aug-1988') months_between
,new_time(sysdate, 'PST', 'AST') newtime
,next_day(sysdate, 'SUNDAY') next_weekday
,round (to_date (sysdate),'YEAR') rounding_year
,round (to_date (sysdate),'Q') rounding_quarter
,round (to_date (sysdate),'MONTH') rounding_month
,sysdate sys_date
,systimestamp sys_timestamp
,trunc (sysdate) trunc_time
FROM DUAL;
SELECT least('01-jan-2016','01-jan-2017') least_date
,greatest ('01-jan-2016','31-dec-2015') greatest_date
, sign (to_date('01-jan-2016') - to_date('01-jan-2017')) date_sign_ex1
, sign (to_date('01-jan-2020') - to_date('01-jan-2017')) date_sign_ex2
, sign (to_date('01-jan-2019') - to_date('31-dec-2017')) date_sign_ex2
, to_date('01-jan-2016') - to_date('01-jan-2017') subtract_dates
FROM DUAL;
Comments
Post a Comment