NOW() : Current Date & Time in MySQL

SELECT NOW(); 
Output is 2020-09-17 16:49:41 , this is in the format YYY-MM-DD HH:MM:SS

Now as a number ( SELECT NOW() + 0 )
20160917165099.000000

NOW() to get todays, yesterday and tomorrow date with time with sample queries


SELECT NOW()- interval 1 HOUR  as One_hour_back,
 NOW() as Present, 
 NOW()+ interval 1 HOUR as One_hour_After
One_hour_backPresentOne_hour_After
2025-10-05 20:54:032025-10-05 21:54:032025-10-05 22:54:03

Yesterday & Tomorrow date by using NOW()

SELECT NOW()- interval 1 day  as Yesterday, 
NOW() as Today, 
NOW()+ interval 1 day as Tomorrow
YesterdayTodayTomorrow
2025-10-04 21:54:032025-10-05 21:54:032025-10-06 21:54:03

Queries using Date and Time

We may require to collect records of last 5 hours or last 24 hours. Here are some queries to find out records based on date and times.
Queries using Date with time

Last Month , Today and Next Month

SELECT NOW()- interval 1 month  as LastMonth, 
NOW() as Today, 
NOW()+ interval 1 Month as NextMonth
Last MonthTodayNext Month
2025-09-05 21:54:032025-10-05 21:54:032025-11-05 21:54:03

Matching only date part ( not time ) with datetime field or Now()

We may store date with time in a table in the above mentioned date and time format. However we can compare the date part only ( without time ) to match the records. Example : We may be storing date and time of login of members in a table but want display all the login members of today or a particular date.
SELECT * from table_name WHERE DATE(date_column)='2019-12-26'
To match current or today's date
SELECT * from table_name WHERE DATE(date_column)=CURDATE()

Read more on CURDATE()

Adding current date and time by default to a record.

While storing a record MySQL can automatically insert date and time in a column. Read more on how to store default date and time in MySQL table here.
SQL Date References Group By in Date field DAYOFWEEK() : Get weekdays like Sunday , Monday .. etc
SQL file using NOW() queries
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com




SQL Video Tutorials










We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer