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 ); |
Output:-
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; |
Output:-
+-------+---------+------------+
| 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'; |
Output:-
+-------+---------+
| Empid | Empname |
+-------+---------+
| 2 | Komal |
| 2 | Sandeep |
| 2 | suman |
+-------+---------+
3 rows in set (0.03 sec)
|

|