A timestamp is used to catch the dates and times.
Understand with Example
The Tutorial illustrate an example to create a SQL Between Timestamp. The table 'Stu_Table' is created with the help of create statement.
Create Table
CREATE TABLE Stu_Table (
Stu_Id varchar(2),
Stu_Name varchar(10),
Stu_Dob timestamp NOT NULL );
|
Insert Date Into Stu_Table
Now insert into statement is used to add the records or rows into a 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 00:00:00 | | 2 | ajay | 1985-04-19 00:00:00 | | 3 | Santosh | 1986-11-16 00:00:00 | +--------+----------+---------------------+ |
Query
The given below query return you the list of records enlisted in the select statement. The Where clause restrict the select query and return you the records from stu_Dob column 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 00:00:00 | | 2 | ajay | 1985-04-19 00:00:00 | +--------+----------+---------------------+ |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: SQL Between Timestamp
Post your Comment