SQL Between Date

The Tutorial help you to understand SQL Between Date. In this Tutorial, we define a table 'Stu_Table'.

SQL Between Date

     

The Tutorial help you to understand SQL Between Date. In this Tutorial, we define a table 'Stu_Table'. The create table statement is used to create a table 'Stu_Table'.  

Create Table Stu_Table

Create Table Stu_Table (Stu_Id varchar(2), Stu_Name varchar(15), Stu_Dob date);

Insert Data Into Stu_Table

The insert into statement add the records or rows into the table 'stu_table'.

insert into stu_table values('1', 'komal', '1984-10-27');
insert into stu_table values('2', 'ajay', '1985-04-19');
insert into stu_table values('3', 'santosh', '1986-11-16');

Stu_Table

+--------+----------+------------+
| Stu_Id | Stu_Name | Stu_Dob    |
+--------+----------+------------+
| 1      | komal    | 1984-10-27 |
| 2      | ajay     | 1985-04-19 |
| 3      | santosh  | 1986-11-16 |
+--------+----------+------------+

Query

The given below Query return you the record from a table 'Stu_Table'. The Where Query restrict select Query and show you the  record between ' '1984-01-01' And '1986-1-1'.

Select * From Stu_Table
Where Stu_Dob Between '1984-01-01' And '1986-1-1';

Result

+--------+----------+------------+
| Stu_Id | Stu_Name | Stu_Dob    |
+--------+----------+------------+
| 1      | komal    | 1984-10-27 |
| 2      | ajay     | 1985-04-19 |
+--------+----------+------------+

Advertisements

Share on Google+Share on Google+

SQL Between Date

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

Advertisements

Ads
 

Discuss: SQL Between Date   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads