MySQL Now function is one of the MySQL Date Functions, which returns the current Date and Time in YYYY-MM-DD HH:MM:SS or YYYYMMDDHHMMSS.uuu format. The basic syntax of the NOW() Function in MySQL is as shown below:
MySQL NOW function Example
The following query shows you the basic use of this now function to get the current date and time.
SELECT NOW() AS 'Todays date and Time';
The following Date Function query explains to you what happens when we add value to this now function.
SELECT NOW() + 5;
SELECT NOW(), NOW() + 5;
From the above screenshot, it added those values to the current date and time. I mean, seconds to current date and time. Next, it is displaying the date in YYYYMMDDHHMMSS string format
MySQL NOW Example 2
In this example, we show you how to use this Now function on columns. Here, we are using a datediff function to find the difference between now and the Hire Date column value.
For this demonstration, we are using Workbench to write a query against the customer database.
SELECT EmpID, FirstName, LastName, Occupation, YearlyIncome, Sales, HireDate, DATEDIFF(NOW(), HireDate) AS Difference FROM `MySQL Tutorial`.customer;