MySQL: NOW Function

  • Post author:
  • Post category:MySQL
  • Post comments:1 Comment
MySQL NOW Function

In this guide, we will explain how to use the MySQL NOW function with syntax and examples.

Description

The MySQL NOW function returns the current date and time.

Syntax

The syntax for the NOW function in MySQL is:

NOW( )

Parameters or Arguments

There are no parameters or arguments for the NOW function.

Note

  • The NOW function will return the current date as a ‘YYYY-MM-DD HH:MM:SS’ format, if used in a string context.
  • The NOW function will return the current date as a YYYYMMDDHHMMSS format, if used in a numeric context in versions of MySQL prior to MySQL 4.1.13.
  • The NOW function will return the current date as a YYYYMMDDHHMMSS.uuuuuu format, if used in a numeric context in versions of MySQL 4.1.13 and newer.
  • The CURRENT_TIMESTAMPLOCALTIME, and LOCALTIMESTAMP functions are synonyms for the NOW function.

Applies To

The NOW function can be used in the following versions of :

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

Example

Let’s look at some NOW function examples and explore how to use the NOW function.

For example:

mysql> SELECT NOW();
Result: '2014-01-28 13:48:41'

mysql> SELECT NOW() + 0;
Result: 20140118134841.000000

mysql> SELECT NOW() + 1;
Result: 20140118134842.000000

Next Topic : Click Here

This Post Has One Comment

Leave a Reply