SQL Date Between

Mysql Date Between return the date between the two existing date.

SQL Date Between

SQL Date Between

     

Mysql Date Between return the date between the two existing date.

Understand with Example

The Tutorial illustrate an example from 'Date Between in SQL'. To understand this example we create a table 'Employee1'.

Step1:-create table name EMPLOYEE1 in the database:-

Query:-

 

 

 

CREATE TABLE EMPLOYEE1 (
ID int(2) NOT NULL auto_increment,
EMPNAME varchar(30),
ATTENDENCE varchar(10), 
DAT date NOT NULL default '0000-00-00',
PRIMARY KEY (ID)
) ;

Output:-

Step2:-Insert the values in the table by giving the query given below:-

Query:-

INSERT into EMPLOYEE1 VALUES ('01','Girish','P','2008-12-01'),
('02','Komal','A','2008-12-02'),
('03','Mahendra','P','2008-12-03'),
('04','Sandeep','A','2008-12-04'),
('05','Amit','P','2008-12-05');

Output:-

Step3:-Write the query given to view the details for extracting data between the two given dates:-

Query:-

SELECT * FROM EMPLOYEE1 
WHERE DAT BETWEEN '2008-12-01' AND '2008-12-03';

Output:-