| Author: Abhinav Dawra 05 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
Hi,
You can use one of the 2 approaches:
select * from <tablename> where <datecolumn> between date1 and date2;
OR
select * from <tablename> where <datecolumn> >= date1 and <datecolumn> <= date2;
(The second query can be used for inclusion/exclusion of boundary values)
Thanks, Abhinav Please rate if you find this answer useful
|
| Author: ABitSmart 05 Jul 2009 | Member Level: Diamond | Rating:  Points: 2 |
How is this different from your previous question you just posted? You did see you got the same answer from the same users, so there's no point repeating the question.
Please do not post multiple posts for the same question.
|
| Author: Ashok 05 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
hi, try this query....
select * from [tablename] where dateadd(dd,datediff(dd,0,[columnname]),0) between dateadd(dd,datediff(dd,0,'31-Mar-2009'),0) and dateadd(dd,datediff(dd,0,'19-May-2009'),0)
Please rate this post, if it is useful for you.
Thanks & Regards Ashok
|
| Author: Deepika Haridas 05 Jul 2009 | Member Level: Diamond | Rating:  Points: 2 |
Hi,
Just need to write
select col1,col2 from [tablename] where date between date1 to date2;
Based on the date format needed convert it.
Thanks & Regards, Deepika Editor
If U want to shine like a SUN..First U have to burn like the SUN!! Need a Guide? Join my mentor program..
|
| Author: Williams 05 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
Hi,
If u want only between dates then the query is
select <columns> from <table> where convert(char(8),<date column>,112) between convert(char(8),<date1>,112) and convert(char(8),<date2>,112)
If u want time part also then the query is
select <columns> from <table> where convert(char(16),<date column>,120) between convert(char(16),<date1>,120) and convert(char(16),<date2>,120)
|
| Author: Raj 06 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
Hi,
SELECT columns FROM table WHERE dateColumn BETWEEN startDate AND endDate
Thanks, Raj
|
| Author: Krishnaveni 06 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
select * from table t WHERE convert(datetime,CONVERT(VARCHAR,t.Startdate,101)) BETWEEN convert(datetime,CONVERT(VARCHAR,'01/02/2009',101)) AND convert(datetime,CONVERT(VARCHAR,'05/04/2009',101))
|
| Author: ketha 06 Jul 2009 | Member Level: Silver | Rating:  Points: 2 |
select * from TableName where ColumnName >= FromDate and ColumnName <= ToDate
|
| Author: MANIKANDAN 06 Jul 2009 | Member Level: Silver | Rating:  Points: 2 |
select datecolumn from datetable where datecolumn between startdate and todate
|
| Author: Devendra 06 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
select col1,col2 from [tablename] where date between date1 to date2;
|
| Author: Rajesh 07 Jul 2009 | Member Level: Bronze | Rating:  Points: 2 |
Hi,
use this if u want the result inbetween the two dates
SELECT columns FROM table WHERE dateColumn BETWEEN startDate AND endDate
use this if u want the result two particulars dates
SELECT columns FROM table WHERE dateColumn in (date1, date2)
|