SQL Server - Select Query - Asked By Bhagya Kabbure on 16-Apr-10 06:10 AM

Hi

I want to write query to retrieve the data from table on the basis of date.
Select all the data from date1 to date2

Plz Help
Thank You
Sagar P replied to Bhagya Kabbure on 16-Apr-10 06:21 AM
You can write a query for that like;

SELECT *
FROM tbldata
WHERE datee BETWEEN startdate AND enddate


ALso you can try something like this in Where clause;

SELECT *
FROM tbldata
where datefield >= start_date and datefield <= end_date
Super Man replied to Bhagya Kabbure on 16-Apr-10 08:22 AM

SqlCommand cmd = new SqlCommand("select * from table1 where date>" + d1 + " and date<" + d2,conn);

Goniey N (Mr. G) replied to Bhagya Kabbure on 16-Apr-10 08:41 AM
Try This Query :

SELECT * FROM Employee WHERE edate >= date1 AND edate <= date2;


//It Will Display All Details Of The Employee Table Whose Date Is Between "date2" To "date1".


//I Hope This Query Will Clear You & Solved your Problem....
Firoz replied to Goniey N (Mr. G) on 17-Apr-10 12:05 AM
HI,
try out following query
query=select * from employee where Date between "+startdate+" and "+enddate+";
it will help you.
thanks.
Firoz replied to Goniey N (Mr. G) on 17-Apr-10 12:06 AM
HI,
try out following query
query=select * from employee where Date between "+startdate+" and "+enddate+";
it will help you.
thanks.
Firoz replied to Goniey N (Mr. G) on 17-Apr-10 12:08 AM
Sorry,
i am try to reply other but i am forgot and reply to you
regards
Firoz
San B M replied to Bhagya Kabbure on 17-Apr-10 01:23 AM
try this one 

Select * from tblname where columnDate between min(columnDate) and max(columnDate)

regards 
San B M