From the course: Oracle Database 12c: Basic SQL
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Using MONTHS_BETWEEN - Oracle Database Tutorial
From the course: Oracle Database 12c: Basic SQL
Using MONTHS_BETWEEN
- [Instructor] The Oracle months_between function allows us to calculate how may months have passed between two distinct dates. Let's see it in action. We'll start by selecting the current sysdate and the hire_date column from the employees table. Note that since sysdate is a pseudocolumn, that is, it is calculated on the fly, and returns the current date and time, of the Oracle database server, while hire_date is an actual column of the employees table, the output will show us a repeating sysdate value for each row returned, while the hire_date column will actually show us the date when the employee was hired. That's because, again, sysdate is calculated on the fly. It's a pseudocolumn, not part of the table, while hire_date is indeed retrieved from the employees table. Okay, so back to business. So let's say we were calculate how many months have passed between the current date, sysdate, and the hire date of the employee. In order accomplish that, we simply add a months_between…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
Introduction to functions1m 39s
-
(Locked)
Using SUBSTRING, LENGTH, and CONCAT2m 50s
-
(Locked)
Using LENGTH1m 4s
-
(Locked)
Using CONCAT4m 48s
-
(Locked)
Using LOWER and UPPER2m 44s
-
(Locked)
Using INSTR4m 32s
-
(Locked)
Using RPAD and LPAD3m 31s
-
(Locked)
Using TO_CHAR to convert numbers1m 34s
-
(Locked)
Using TO_CHAR to format DATE values2m 59s
-
(Locked)
Using TO_CHAR to filter DATE values1m 57s
-
(Locked)
The special Oracle DUAL table1m 18s
-
(Locked)
Using ROUND1m 15s
-
(Locked)
Using TRUNC1m 36s
-
(Locked)
Using SYSDATE1m 59s
-
(Locked)
Using SYSTIMESTAMP1m 37s
-
(Locked)
Using MONTHS_BETWEEN3m 2s
-
(Locked)
Using ADD_MONTHS1m 17s
-
-
-
-
-
-