NOW() : Current Date & Time in MySQL

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

Now as a number
20160917165099.000000

Yesterday & Tomorrow date by usign NOW()

SELECT NOW()- interval 1 day  as Yesterday, NOW() as Today, NOW()+ interval 1 day as Tomorrow
YesterdayTodayTomorrow
2019-02-22 14:23:142019-02-23 14:23:142019-02-24 14:23:14

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
2019-01-23 14:23:142019-02-23 14:23:142019-03-23 14:23:14

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.

Visitors Rating
Your Rating




Google+

Post Comment This is for short comments only. Use the forum for more discussions.








HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2019 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer