view counter

More fun with dates

Thanks to Scott Wesley for this story

Last week I had a post reminding us to consider the time component of our date data types.

Oracle Virtualization and Cloud Consulting
view counter

Here I'm just listing some fun with dates, either from single row sql expressions or cool little queries.

sysdate today
,trunc(sysdate) midnight_today
,trunc(sysdate)+1/86400 one_second
,trunc(sysdate)+2/24 two_hours
,trunc(sysdate)+30/60/24 thirty_minutes
,trunc(sysdate) + interval '2:30' hour to minute two_hour_thirty
,trunc(sysdate,'mm') start_of_month
,trunc(sysdate,'yy') start_of_year
,trunc(sysdate,'yy')+6 financial_year
,extract(year from sysdate) year_as_number
,to_char(sysdate,'yyyy') year_as_varchar2
,(sysdate - add_months(sysdate,6)) year to month interval_months
,(Sysdate-(sysdate+2+30/60/24)) day(9) to second interval_daysec

Read the entire article at its source

view counter