Q.Using the EMPLOYEE table of the CARSHOWROOM database to illustrate the working of date and time functions:
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →Extract day/month/year from the EMPLOYEE table's DOJ column with DAY()/MONTH()/YEAR(), then use DAYNAME() in a WHERE clause to exclude Sunday joiners while displaying the full date in words.
This is a code/query task on the real EMPLOYEE table of CARSHOWROOM:
| EmpID | EmpName | DOB | DOJ | Designation | Salary |
|---|---|---|---|---|---|
| E001 | Rushil | 1994-07-10 | 2017-12-12 | Salesman | 25550 |
| E002 | Sanjay | 1990-03-12 | 2016-06-05 | Salesman | 33100 |
| E003 | Zohar | 1975-08-30 | 1999-01-08 | Peon | 20000 |
| E004 | Arpit | 1989-06-06 | 2010-12-02 | Salesman | 39100 |
| E006 | Sanjucta | 1985-11-03 | 2012-07-01 | Receptionist | 27350 |
| E007 | Mayank | 1993-04-03 | 2017-01-01 | Salesman | 27352 |
| E010 | Rajkumar | 1987-02-26 | 2013-10-23 | Salesman | 31111 |
(a) DAY(), MONTH() and YEAR() each pull one numeric component out of the DOJ date column:
SELECT DAY(DOJ), MONTH(DOJ), YEAR(DOJ) FROM EMPLOYEE;
Applied to every employee's DOJ, this gives one row per employee:
| DAY(DOJ) | MONTH(DOJ) | YEAR(DOJ) |
|---|---|---|
| 12 | 12 | 2017 |
| 5 | 6 | 2016 |
| 8 | 1 | 1999 |
| 2 | 12 | 2010 |
| 1 | 7 | 2012 |
| 1 | 1 | 2017 |
| 23 | 10 | 2013 |
(b) The request is to show the FULL date in words ("Wednesday, 26, November, 1979") but only for employees who didn't join on a Sunday. DAYNAME() returns the weekday as a word, so it does double duty here — once in the WHERE clause to exclude Sundays, and once in the SELECT list to display it:
SELECT DAYNAME(DOJ), DAY(DOJ), MONTHNAME(DOJ), YEAR(DOJ)
FROM EMPLOYEE
WHERE DAYNAME(DOJ)!='Sunday';
Checking each DOJ's weekday: 2017-12-12 → Tuesday, 2016-06-05 → Sunday, 1999-01-08 → Friday, 2010-12-02 → Thursday, 2012-07-01 → Sunday, 2017-01-01 → Sunday, 2013-10-23 → Wednesday. The three Sunday joiners (Sanjay, Sanjucta, Mayank) are filtered out, leaving 4 rows:
| DAYNAME(DOJ) | DAY(DOJ) | MONTHNAME(DOJ) | YEAR(DOJ) |
|---|---|---|---| …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.