Mysql Date in between

The Tutorial illustrates an example Mysql date in between . In this

Mysql Date in between


The Tutorial illustrates an example Mysql date in between . In this Tutorial we illustrate an example that help you to get the date in between.

Query for creating table:-

The create table statement create a table employees1 with field name and data type respectively.

mysql> CREATE TABLE employee1(
-> Empid int(10),
-> Empname varchar(60),
-> date date );


Query for inserting data:-

The insert into add the records or rows value into the table 'employee1'.

mysql> insert into employee1 values('2','Komal','2008-12-23');
Query OK, 1 row affected (0.03 sec)

mysql> insert into employee1 values('2','Sandeep','2008-12-24');
Query OK, 1 row affected (0.02 sec)

mysql> insert into employee1 values('2','suman','2008-12-25');
Query OK, 1 row affected (0.03 sec)

Query for Viewing data:-

The select return and display  the records from the table'employee1'.

mysql> select * from employee1;


| Empid | Empname | date       |
|     1 | Girish  | 2008-12-20 |
|     2 | Komal   | 2008-12-21 |
|     3 | vineet  | 2008-12-21 |
|     4 | Amit    | 2008-12-20 |
|     2 | Komal   | 2008-12-23 |
|     2 | Sandeep | 2008-12-24 |
|     2 | suman   | 2008-12-25 |
7 rows in set (0.00 sec)

Query for extracting record using date-in- between:-

The given below Query return you the Empid,Empname from table employee 1 where the value of date lies between  '2008-12-23'and '2008-12-25'.

mysql> select Empid,Empname from employee1 where date between '2008-12-23'and '2008-12-25';


| Empid | Empname |
|     2 | Komal   |
|     2 | Sandeep |
|     2 | suman   |
3 rows in set (0.03 sec)


Share on Google+Share on Google+

Mysql Date in between

Posted on: May 24, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Mysql Date in between  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
May 29, 2011
very good tut

i had the pro in giving '' to date thats is solved by ur useful guide
October 21, 2011

Thanks lot:)
November 4, 2011
Weak post

The only relevant part of this post is the table data, the between clause in the query and the result set. There is no explanation of the explanation of the result set of the clause itself!
November 9, 2011
Awesome, thanks

I am working on a financial report for my wife and this just gave a big peace of mind. thanks a lot for that post
aruna reddy
February 27, 2013
i have a mysql search query

in my site two fields are there minimum price and maximum price when i click on serch button in between records i want to display soo tel me your suggetion ,when i give min price 10 lachs and max price 2o lacks sooo i want to get the records in between 10 lachs and 20 lachs
February 4, 2012
Good info

I just wanted to say good information here, exactly what I needed. I got my date code working much simpler. (I noticed one niggle which is that words such as select should be SELECT in uppercase).
October 8, 2012
Dates included?

Hello, Thanks for the tutorial. My question is do you included the dates or simply its in between? If any data are there with the same date? Thanks Rakesh