Share on Google+Share on Google+

MySql Time Interval

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 |
+---------------------+

 

 

 

 

Advertisements

Posted on: December 9, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.