QuizzesDate & Time Functions — Concept Check
intermediate
mysql

Date & Time Functions — Concept Check

Questions on Date & Time Functions. NOW(), CURDATE(), DATE_ADD(), DATEDIFF(), DATE_FORMAT(), UNIX_TIMESTAMP(), and STR_TO_DATE() are essential for date arithmetic, formatting, and timezone-aware applications.

8 minutes 8 questions Pass at 70%
Time Limit
8 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

8 questions on Date & Time Functions — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A developer needs to find the number of days between two dates: '2025-12-31' and '2025-01-01'. Which function should they use?

    • ADATEDIFF
    • BDATE_ADD
    • CDATE_SUB
    • DTIMESTAMPDIFF
  2. 2.A query uses DATE(created_at) = CURDATE() to filter results. What is a better approach to maintain index efficiency?

    • AUse created_at BETWEEN CURDATE() AND CURDATE() + INTERVAL 1 DAY
    • BUse DATE_FORMAT(created_at, '%Y-%m-%d') = CURDATE()
    • CUse created_at = CURDATE()
    • DUse created_at >= CURDATE() AND created_at < CURDATE() + INTERVAL 1 DAY
  3. 3.A system stores timestamps in UTC but needs to display them in local time. Which function helps convert UTC to local time?

    • ACONVERT_TZ
    • BDATE_FORMAT
    • CSTR_TO_DATE
    • DUNIX_TIMESTAMP
  4. 4.A developer wants to add one month to the current date. Which function should they use?

    • ADATE_ADD(NOW(), INTERVAL 1 MONTH)
    • BDATE_SUB(NOW(), INTERVAL 1 MONTH)
    • CDATE_ADD(NOW(), INTERVAL 30 DAY)
    • DDATE_FORMAT(NOW(), '%Y-%m-%d')
  5. 5.A report requires the current date and time formatted as '22 Mar 2026 14:30'. Which function is appropriate?

    • ASTR_TO_DATE('22 Mar 2026 14:30', '%d %b %Y %H:%i')
    • BUNIX_TIMESTAMP(NOW())
    • CDATE_FORMAT(NOW(), '%d %b %Y %H:%i')
    • DCURDATE()
  6. 6.A developer is confused why their TIMESTAMP column shows different times on different servers. What could be the reason?

    • AIncorrect use of DATE_FORMAT
    • BImproper use of UNIX_TIMESTAMP
    • CUsing DATETIME instead of TIMESTAMP
    • DServer timezone differences
  7. 7.Which function returns the current date and time at the start of a statement execution in MySQL?

    • ANOW()
    • BSYSDATE()
    • CUTC_TIMESTAMP()
    • DCURDATE()
  8. 8.A developer needs to parse a date string '22-03-2026' into a date format. Which function should they use?

    • ADATE_FORMAT('22-03-2026', '%d-%m-%Y')
    • BSTR_TO_DATE('22-03-2026', '%d-%m-%Y')
    • CUNIX_TIMESTAMP('22-03-2026')
    • DDATE_ADD('22-03-2026', INTERVAL 0 DAY)