Home Tutorial Php Sql MySql Time Interval

 
 

Share on Google+Share on Google+
MySql Time Interval
Posted on: December 9, 2010 at 12:00 AM
Advertisement
This example illustrates how to get date and time between specific time interval.

MySql Time Interval

This example illustrates how to get date and time between specific time interval.

In this example we create a query "select lastAccess from emp WHERE lastAccess BETWEEN '2008-09-01' AND '2008-12-01'" to find the data between specified interval. The BETWEEN and AND keyword are used for it.

 

Query
 
 select lastAccess from emp 
   WHERE lastAccess BETWEEN '2008-09-01' AND '2008-12-01';
Output
 
+---------------------+
| lastAccess          |
+---------------------+
| 2008-11-26 11:13:08 |
| 2008-10-01 13:17:45 |
| 2008-09-01 13:17:45 |
| 2008-11-26 11:13:08 |
| 2008-11-26 11:13:08 |
| 2008-11-26 11:13:08 |
| 2008-11-26 11:13:08 |
| 2008-11-26 11:13:08 |
| 2008-11-26 11:13:08 |
| 2008-11-26 11:13:08 |
+---------------------+

 

 

 

 

Advertisement

Related Tags for MySql Time Interval:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 9, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com