Some Date Function Examples In Oracle
Determining the First Date or Day in a Month In Oracle
You need to dynamically determine the first date in a given month at runtime. Oracle’s TRUNC function can be used on dates to perform start-of-period calculations, such as the first day of the month.
Our recipe was written on May 21st. Any arbitrary date, datetime, or timestamp expression can be
Calculating the Day of the Week in Oracle
Determining the day of the week, and also indicate whether it’s considered a work day or weekend.
select to_char(sysdate,’Day’) Day_Of_Week,
when to_char(sysdate,’D’) in (1,7) then ‘Weekend’
Running my example on a Monday returns the following results.
Conversely, running my example on a Saturday shows this output.
Converting Strings to Datetime Values in Oracle