How To Use Oracle Date Format

How To Use Oracle Date Format

December 12, 2019
Oracle DBA
oracle dba oracle database management database management system database oracle performance tuning oracle sql learn sql learn personal injury attorney new york mesothelioma lawyers mesothelioma lawyers new york mesothelioma lawyer the stock market plumbing retirement planning barclays stock broker financial advisor personal retirement financial advisor

This tutorial page is based on examples to make it easier to follow. Oracle Date Format types are on this link. The most basic way to use a date format is as the next example:

SELECT TO_DATE('20120921','YYYYMMDD')
  FROM DUAL;

dba oracle dba database management system oracle performance tuning oracle date format oracle to_date oracle to_date in oracle personal injury attorney new york mesothelioma lawyers mesothelioma lawyers new york mesothelioma lawyer the stock market plumbing retirement planning barclays stock broker financial advisor personal retirement financial advisor

In the example above the Oracle date format has declared a date mask after string ‘20120921‘. The oracle date mask is a text that is formatted in the same way and in order that is the data value. In this Oracle database management system example the year is as “YYYY” + month as “MM” + day number as “DD”. The oracle query returns the oracle date value of September 21st 2012.

To find the last day of any year, our recommends to do it the following way. For example in the oracle date format we would like to get the last day number of year 2000.

SELECT TO_DATE('20010101','YYYYMMDD') -1
  FROM DUAL;

dba oracle dba database management system oracle performance tuning oracle date format oracle to_date oracle to_date in oracle personal injury attorney new york mesothelioma lawyers mesothelioma lawyers new york mesothelioma lawyer the stock market plumbing retirement planning barclays stock broker financial advisor personal retirement financial advisor

The example above is using the 1st of January 2001 and subtract 1 day of it. The same way you can find last day of February month. It can be different by every 4th year and to use the following example it can be archived easily. In the next example with date format in Oracle and we will need to find the last day of February 1998.

SELECT TO_DATE('19980301','YYYYMMDD') -1
  FROM DUAL;

dba oracle dba database management system oracle performance tuning oracle date format oracle to_date oracle to_date in oracle personal injury attorney new york mesothelioma lawyers mesothelioma lawyers new york mesothelioma lawyer the stock market plumbing retirement planning barclays stock broker financial advisor personal retirement financial advisor

In the last example above we took the next month’s first day (March 1st 1998) and subtract 1 day of it.

See Also:
Oracle Select Home

Leave a Reply

Your email address will not be published. Required fields are marked *

*