MySQL NOW Function

MySQL Now is one of the 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 is as shown below:

NOW();

MySQL NOW function Example

The following NOW method query shows you the basic use of this one to get the current DateTime.

SELECT NOW();
2019-02-19 09:50:46

As you can see from the above screenshot, it returns today’s date and Time in YYYY-MM-DD HH:MM:SS format. Let us see another MySQL example of the Date method with an Alias Name.

SELECT NOW() AS 'Todays date and Time';

The following MySQL NOW Function query explains to you what happens when we add value to this.

SELECT NOW() + 5;

SELECT NOW(), NOW() + 5;
MySQL Now  Function Example 4

From the above screenshot, it added those values to the current datetime. I mean, seconds to the current date and time. Next, it displays the same in YYYYMMDDHHMMSS string format.

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.

We use Workbench to write a query against the customer database for this demonstration.

SELECT EmpID,
       FirstName,
       LastName,
       Occupation,
       YearlyIncome,
       Sales,
       HireDate,
       DATEDIFF(NOW(), HireDate) AS Difference
 FROM customer;
MySQL Date Now Function Example 5