Code With Coffie
  • HOME
  • ABOUT US
  • PORTFOLIO
  • JAVASCRIPT
    • Vue.js
  • PHP
    • PHP OOPS
    • LARAVEL
    • WORDPRESS
  • MYSQL
    • DATETIME
  • DSA
    • LEETCODE
  • Home
  • Blog
  • MYSQL
  • DATETIME
  • 🔥 Basic Date-Time Questions in MySQL

🔥 Basic Date-Time Questions in MySQL

Jun 13, 2025 by codewithhemu

1.Fetch today’s records

SELECT * FROM table WHERE DATE(col)=CURDATE();

2.Get records from yesterday

SELECT * FROM table WHERE col >= CURDATE()-INTERVAL 1 DAY AND col < CURDATE();

3.This month’s records

SELECT * FROM table WHERE MONTH(col)=MONTH(CURDATE()) AND YEAR(col)=YEAR(CURDATE());

4.Last 7 days

WHERE col >= CURDATE() - INTERVAL 7 DAY

5.Extract month name

SELECT MONTHNAME(col) FROM table;

6.Specific weekday (e.g. Monday)

WHERE DAYOFWEEK(col)=2

7.Time difference between TIME columns

SELECT TIMEDIFF(time_end, time_start)FROM table;

8.Birthdays today

WHERE MONTH(birthdate)=MONTH(CURDATE()) AND DAY(birthdate)=DAY(CURDATE())

9.Date part only

SELECT DATE(col) FROM table;
  • Share:
Previous Article 🔥 Real-World Scenario-Based Date-Time Questions in MySQL
Next Article 🔥 Medium Level Date-Time Questions in MySQL
No comments yet! You be the first to comment.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

category

  • DATETIME (6)
  • DJANGO (1)
  • Docker (1)
  • DSA (21)
  • DSA PRACTICE (4)
  • ENGLISH READING (1)
  • JAVASCRIPT (69)
  • LARAVEL (40)
  • LeetCode (1)
  • MYSQL (45)
  • PHP (21)
  • PHP OOPS (16)
  • PROGRAMME (1)
  • PYTHON (7)
  • REACT JS (6)
  • STAR PATTERN PROGRAMME (7)
  • Uncategorized (20)
  • Vue.js (5)
  • WORDPRESS (15)

Archives

  • March 2026
  • October 2025
  • September 2025
  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • January 2023

Tags

Certificates Education Instructor Languages School Member

Building reliable software solutions for modern businesses. Sharing practical tutorials and real-world project insights to help developers grow with confidence.

GET HELP

  • Home
  • Portfolio
  • Privacy Policy
  • Terms & Conditions
  • Disclaimer
  • Contact Us

PROGRAMS

  • Software Development
  • Performance Optimization
  • System Architecture
  • Project Consultation
  • Technical Mentorship

CONTACT US

  • Netaji Subhash Place (NSP) Delhi
  • Tel: + (91) 8287315524
  • Email: contact@codewithcoffie.com

Copyright © 2026 LearnPress LMS | Powered by LearnPress LMS