Changes

Jump to: navigation, search

Working with Dates and Times in MySQL

587 bytes added, 15:48, 23 October 2007
Date and Time Functions
In addition to providing mechanisms for storing dates and times, MySQL also provides a wide range of functions that can be used to manipulate dates and times. The following table provides a list of the more common functions available for working with times and dates in MySQL:
A useful point to note about these functions is that you can easily experiment without writing any data to a table. For example:
 
<pre>
mysql> SELECT NOW();
+---------------------+
| NOW() |
+---------------------+
| 2007-10-23 11:46:31 |
+---------------------+
1 row in set (0.00 sec)
</pre>
 
To try out a combination of functions in a single statement (for example to find the day of the week):
 
<pre>
mysql> SELECT MONTHNAME(NOW());
+------------------+
| MONTHNAME(NOW()) |
+------------------+
| October |
+------------------+
1 row in set (0.00 sec)
</pre>
<table border="1" cellspacing="0">

Navigation menu