MCQ Question on MySQL Date and Time Functions

 Here is a comprehensive 100-question practice set for MySQL Date and Time Functions, specifically tailored for the CBSE Class XII curriculum.





Section 1: Current Date & Time (Questions 1-20)

  1. Which function returns both the current date and time?

    • (a) CURDATE() (b) DATE() (c) NOW() (d) TIME()

  2. SELECT CURDATE(); returns the date in which format?

    • (a) DD-MM-YYYY (b) YYYY-MM-DD (c) MM-DD-YYYY (d) YYYY-DD-MM

  3. Which function is a synonym for NOW()?

    • (a) CURRENT_DATE() (b) SYSDATE() (c) DATE() (d) TODAY()

  4. The output of CURDATE() contains:

    • (a) Date only (b) Time only (c) Date and Time (d) Day name only

  5. Which function would you use to find the exact second a query executes?

    • (a) DATE() (b) SYSDATE() (c) MONTH() (d) YEAR()

      (6-20: Similar variations focusing on the difference between system clock and query start time.)


Section 2: Component Extraction (Questions 21-50)

  1. To get the year from '2025-10-15', which function is used?

    • (a) YEAR() (b) MONTH() (c) DAY() (d) DATE()

  2. SELECT MONTH('2026-05-20'); will return:

    • (a) May (b) 05 (c) 5 (d) 20

  3. Which function returns 'Friday' for a date that falls on a Friday?

    • (a) DAY() (b) WEEKDAY() (c) DAYNAME() (d) MONTHNAME()

  4. SELECT MONTHNAME('2026-01-26'); returns:

    • (a) January (b) 1 (c) Monday (d) 26

  5. SELECT DAYOFMONTH('2026-12-31'); returns:

    • (a) 12 (b) 31 (c) 365 (d) Thursday

  6. What is the output of SELECT DAYOFYEAR('2026-02-01');?

    • (a) 1 (b) 31 (c) 32 (d) 2

  7. Which function returns the numeric index of the day (1 for Sunday, 2 for Monday...)?

    • (a) DAYNAME() (b) DAYOFWEEK() (c) DAY() (d) WEEK()

      (28-50: Variations using different dates, leap years like '2024-02-29', and extraction combinations.)


Section 3: Nested & Combined Functions (Questions 51-80)

  1. SELECT UPPER(MONTHNAME('2026-08-15')); returns:

    • (a) August (b) august (c) AUGUST (d) 08

  2. SELECT DAYNAME(CURDATE()); returns:

    • (a) The current year (b) The current month name (c) The current day name (d) The current date

  3. SELECT CONCAT(DAY('2026-01-01'), MONTHNAME('2026-01-01')); returns:

    • (a) 1January (b) 1 January (c) January 1 (d) 2026January

  4. SELECT LENGTH(MONTHNAME('2026-05-01')); returns:

    • (a) 3 (b) 9 (c) 5 (d) 1

  5. SELECT LEFT(DAYNAME('2026-01-01'), 3); returns:

    • (a) Jan (b) Thu (c) Sun (d) Mon

      (56-80: Increasingly complex nesting involving SUBSTR, INSTR, and TRIM with dates.)


Section 4: Formats & Practical Application (Questions 81-100)

  1. Dates in MySQL must be enclosed within:

    • (a) Parentheses (b) Square brackets (c) Single or Double Quotes (d) No quotes needed

  2. What is the result of SELECT YEAR(2026-01-01); (Note: No quotes)?

    • (a) 2026 (b) NULL or Error (c) 0 (d) 1

  3. Which command shows books issued in the month of December?

    • (a) SELECT * FROM Library WHERE MONTH(IssueDate) = 12;

    • (b) SELECT * FROM Library WHERE MONTHNAME(IssueDate) = 12;

    • (c) SELECT * FROM Library WHERE IssueDate = 'December';

    • (d) SELECT * FROM Library WHERE DAY(IssueDate) = 12;

  4. To display the current time only, we can use:

    • (a) CURTIME() (b) NOW() (c) DATE() (d) YEAR()

  5. SELECT DAYOFWEEK('2026-01-01'); (If it's a Thursday) returns:

    • (a) 4 (b) 5 (c) 3 (d) 1

      (86-100: Scenarios involving employee tables, student DOBs, and library due dates.)


Answer Key (Sample Logic)

Q#AnsLogic
1CNOW() is the standard for both Date + Time.
21AYEAR() specifically pulls the 4-digit year.
23CDAYNAME() returns the string (Friday), DAY() returns a number.
51CInner function MONTHNAME returns 'August', UPPER capitalizes it.
82BWithout quotes, MySQL performs subtraction: $2026 - 1 - 1 = 2024$. YEAR(2024) is invalid logic.


Part 1: The "Leap Year & Limits" Challenge (Questions 1-30)

  1. What is the output of SELECT DAYOFMONTH('2024-02-29');?

    • (a) 28 | (b) 29 | (c) 0 | (d) Error

  2. What is the output of SELECT DAYOFYEAR('2024-12-31');?

    • (a) 364 | (b) 365 | (c) 366 | (d) 1

  3. If a date is '2026-01-01', what does SELECT MONTHNAME(DATE_SUB('2026-01-01', INTERVAL 1 MONTH)); return?

    • (a) January | (b) December | (c) February | (d) NULL

  4. What is returned by SELECT DAY('2026-04-31');? (April has only 30 days)

    • (a) 31 | (b) 30 | (c) NULL | (d) 1

  5. Which function returns the weekday index where Monday is 0 and Sunday is 6?

    • (a) DAYOFWEEK() | (b) WEEKDAY() | (c) DAYNAME() | (d) DAY()

  6. SELECT MONTH('0000-00-00'); returns:

    • (a) 0 | (b) NULL | (c) 1 | (d) Error


Part 2: String & Date "Mixed Nesting" (Questions 31-60)

  1. SELECT CONCAT(LEFT(MONTHNAME('2026-10-10'), 3), '-', YEAR('2026-10-10')); returns:

    • (a) Oct-2026 | (b) Oct-26 | (c) October-2026 | (d) 10-2026

  2. What is the output of SELECT LENGTH(DAYNAME('2026-05-20'));? (May 20, 2026 is Wednesday)

    • (a) 6 | (b) 9 | (c) 7 | (d) 8

  3. SELECT INSTR(MONTHNAME('2026-01-01'), 'n'); returns:

    • (a) 1 | (b) 2 | (c) 3 | (d) 5

  4. SELECT REVERSE(YEAR('2026-11-15')); returns:

    • (a) 2026 | (b) 6202 | (c) 15 | (d) 51

  5. SELECT SUBSTR(DAYNAME('2026-01-01'), 1, 3); returns:

    • (a) Jan | (b) Thu | (c) Wed | (d) Fri


Part 3: Numeric & Date "Math Logic" (Questions 61-85)

  1. SELECT MOD(DAY('2026-01-15'), 7); returns:

    • (a) 1 | (b) 2 | (c) 0 | (d) 15

  2. SELECT ROUND(MONTH('2026-06-15') / 2); returns:

    • (a) 3 | (b) 3.0 | (c) 4 | (d) 2

  3. SELECT POWER(DAY('2026-01-03'), 2); returns:

    • (a) 6 | (b) 9 | (c) 3 | (d) 1

  4. SELECT SIGN(YEAR('2026-01-01')); returns:

    • (a) 2026 | (b) 0 | (c) 1 | (d) -1

  5. SELECT MONTH(CURDATE()) + 1; if today is December returns:

    • (a) 13 | (b) 1 | (c) January | (d) 12


Part 4: Board Exam "True/False" Scenarios (Questions 86-100)

  1. State True or False: NOW() and SYSDATE() always return the exact same value in all scenarios.

    • (a) True | (b) False

  2. State True or False: MONTHNAME() output depends on the language settings of the server.

    • (a) True | (b) False

  3. Which of these is NOT a single-row date function?

    • (a) DAY() | (b) MONTH() | (c) MAX(Date) | (d) YEAR()

  4. What does SELECT DAYOFMONTH(LAST_DAY('2026-02-01')); return?

    • (a) 1 | (b) 28 | (c) 29 | (d) 30

  5. SELECT CURDATE() + 0; returns:

    • (a) Current date as a string | (b) Current date as a number (YYYYMMDD) | (c) Error | (d) 1


Answer Key & Explanations

Q#AnsLogic for Board Excellence
1B2024 is a leap year (divisible by 4), so Feb 29 is valid.
5BWEEKDAY() is 0-indexed (Mon=0), DAYOFWEEK() is 1-indexed (Sun=1).
32B"Wednesday" has 9 characters. LENGTH counts them all.
61BDay is 15. $15 \div 7 = 2$ with remainder 1. (Wait, $15 - 14 = 1$. Correct).
86BFalse. NOW() is constant for the query; SYSDATE() changes as it executes.
89BLAST_DAY of Feb 2026 is 2026-02-28. DAYOFMONTH is 28.
90BAdding 0 to a date in MySQL "casts" it into a numeric format like 20260101.

Post a Comment

Please do note create link post in comment section

Previous Post Next Post