The Oracle date function is used to process the date and time in the Oracle database. The following describes the usage of the Oracle date function in detail.
1) SYSDATE and TRUNC
The two Oracle date functions take the date of the Oracle server system and cut off the decimal part. Observe the following operations:
Create table test_date (name varchar2 (20), p_date date );
Insert into test_date values ('name1', sysdate );
Select * from test_date;
Select * from test_date where p_date = '25-October-05 ';
Select * from test_date where trunc (p_date) = '25-October-05 ';
In Oracle, SYSDATE is used to obtain time information that not only contains the date, but also contains the time information. The time information is actually the fractional part of the number of vertices.
2) ADD_MONTHS
The Oracle date function returns a date with a month difference from the provided date. The function provides the number of months in the future or before. Syntax:
ADD_MONTHS start date, increase or decrease the number of months)
Select add_months ('26-October-05 ', 2) from dual;
Select add_months ('26-October-05 ',-2) from dual;
3) LAST_DAY
Returns the last day of the month that contains the given date. Syntax:
LAST_DAY (date)
Select last_day ('21-September-80') from dual;
4) MONTHS_BETWEEN
Returns the month of the two-day period. Syntax:
MONTHS_BETWEEN: Latest date, earlier date)
Select months_between ('12-October-05 ', '12-September-03') from dual;
Learn about Oracle Text Functions
Syntax for creating an Oracle package
Use of Oracle to_char Functions
Implementation of oracle function return table
How to uninstall an Oracle database in Windows