Mysql Date and Time

Ads
 

Mysql Date and Time

The Tutorial illustrate an example, that help in understanding datetime. In this Tutorial ,we illustrate an example that help you in writing a date time format Query in different ways.

The Tutorial illustrate an example, that help in understanding datetime. In this Tutorial ,we illustrate an example that help you in writing a date time format Query in different ways.

Mysql Date and Time

     

The Tutorial illustrate an example, that help in understanding datetime. In this Tutorial ,we illustrate an example that help you in writing a date time format Query in different ways.

now ( )  :The below Query return you the current date in yyyy-mm-dd and time in hh:mm:ss.

Query for displaying current date and time:-

 

 

 

 

 

mysql> select now()as DateandTime;

Output:-

+---------------------+
| DateandTime |
+---------------------+
| 2008-12-20 12:19:07 |
+---------------------+
1 row in set (0.00 sec)

Query for extracting date from datetime:-

The given below Query return you the current date.

mysql> select day(now())as TodayDate;

Output:-

+-----------+
| TodayDate |
+-----------+
| 20 |
+-----------+
1 row in set (0.00 sec)

Ads

Ads