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 TO_CHAR to filter DATE values

Using TO_CHAR to filter DATE values - Oracle Database Tutorial

From the course: Oracle Database 12c: Basic SQL

Start my 1-month free trial

Using TO_CHAR to filter DATE values

- [Instructor] We can also use Oracle to_char sequel function when filtering for specific date values. Let's start by selecting the first name and hire date columns from our employees table. And let's assume that we want to see only employees who have been hired in the month of January. So in order to accomplish that using the to_char function you can just type where to_char, specify the hire date column and a MON format math inside quotation marks. So we essentially extract only the month from the hire date column. Equals, and inside quotation marks uppercase JAN signifying January. Running this query will show me only employees who have been hired during January. Keep in mind that if we change the format math from MON which returns the month name as a three letter code, so J A N for January for example to MM which returns two digits signifying the month numbers or 01 for January. And run the query as is. The query will return zero records. We'll also have to change JAN to 01 in…

Contents