From the course: Quick Start Guide to SQL

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Date functions

Date functions

- [Instructor] Let's learn about date functions. SYSDATE function returns the current date. So if I give SELECT SYSDATE FROM DUAL, it'll display the current date. We can perform different arithmetic operations on dates. These are some of the date functions that are most commonly used, MONTHS_BETWEEN, ADD_MONTHS, NEXT_DAY. Let's look at some examples to learn about these functions. If I want to calculate the number of months between two dates, I give MONTHS_BETWEEN followed by both the dates, and then I run this. Now it displays the number of months in between these two dates. If I change the order and give 1st of March here, and 3rd of December, this side, then it gives me a negative value. Now if I want to add a set of months to a specific date, then I can give ADD_MONTHS, the date, followed by the number of months to be add. So, now, when I run this, it returns the new date by adding four months to 5th of June, 2021,…

Contents