NOW() : Current Date & Time in MySQL

SELECT NOW(); 
The result is the current date and time for the MySQL session in YYYY-MM-DD HH:MM:SS form.

MySQL can coerce NOW() to a numeric context, but for application code it is clearer to keep temporal values as date/time values and format them explicitly when needed. Example of numeric coercion:
YYYYMMDDHHMMSS.ffffff

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
2026-09-29 13:45:422026-09-29 14:45:422026-09-29 15:45:42

Yesterday & Tomorrow date by using NOW()

SELECT NOW()- INTERVAL 1 DAY  AS Yesterday, 
NOW() AS Today, 
NOW()+ INTERVAL 1 DAY AS Tomorrow
YesterdayTodayTomorrow
2026-09-28 14:45:422026-09-29 14:45:422026-09-30 14:45:42

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
2026-08-29 14:45:422026-09-29 14:45:422026-10-29 14:45:42

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


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-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer