MYSQL NOW Overview

MYSQL NOW Function is used to return system's current data and time. NOW Function will basically return the date and time of that system on which you are running on your query. If running on your system then Now will return your system's data and time and if you are running this function on any remote server than Now Function will return remote server's data and time.

MYSQL NOW Syntax

Syntax for MYSQL Now Function is

SELECT NOW() FROM table_name;

MYSQL NOW Example

Let us look at it with an example

Consider table hostel_list containg list of hostels

+----+-------------------+-----------+----------+
| id | name | occupancy | capacity |
+----+-------------------+-----------+----------+
|  1 | ASHOK BHAVAN | 2 | 1090 |
|  2 | KAILASH BHAVAN | 2 | 990 |
|  3 | RUDRAKSH BHAVAN | 2 | 990 |
|  4 | KAVERI BHAVAN | 1 | 690 |
|  5 | BHAGIRATHI BHAVAN | 4 | 2140 |
|  6 | NARMADA BHAVAN | 6 | 3240 |
|  7 | GANGA BHAVAN | 1 | 780 |
|  8 | YAMUNA BHAVAN | 8 | 4580 |
+----+-------------------+-----------+----------+

MYSQL NOW Example Case 1:

Let us fetch hostel names and their capacities with the current date and time.

SELECT name, capacity, NOW() FROM hostel_list;
+-------------------+----------+---------------------+
| name | capacity | NOW() |
+-------------------+----------+---------------------+
| ASHOK BHAVAN | 1090 | 2016-03-27 14:07:31 |
| KAILASH BHAVAN | 990 | 2016-03-27 14:07:31 |
| RUDRAKSH BHAVAN | 990 | 2016-03-27 14:07:31 |
| KAVERI BHAVAN | 690 | 2016-03-27 14:07:31 |
| BHAGIRATHI BHAVAN | 2140 | 2016-03-27 14:07:31 |
| NARMADA BHAVAN | 3240 | 2016-03-27 14:07:31 |
| GANGA BHAVAN | 780 | 2016-03-27 14:07:31 |
| YAMUNA BHAVAN | 4580 | 2016-03-27 14:07:31 |
+-------------------+----------+---------------------+


This article is contributed by Ankur Rastogi on Sat Jun 04 2016 16:57:45 GMT+0530 (IST)

If you want to add more comments to the article or you see any thing incorrect please write a comment below and we will surely get back to you.