Reputation: 997
I have a gridview and sqldatasource.
Here is the gridview:
+----+--------------+--------+----------+
| No | Names | ID | Date |
+----+--------------+--------+----------+
| 1 | Name1 |1636 |04.15.2012|
| 2 | Name7 |1236 |09.12.2012|
| 3 | Name1 |1136 |08.16.2012|
| 4 | Name3 |1536 |09.25.2012|
| 5 | Name11 |1436 |09.15.2012|
| 6 | Name1 |1836 |09.11.2012|
| 7 | Name2 |1736 |09.15.2011|
| 8 | Name1 |1296 |08.15.2012|
+----+--------------+--------+----------+
And now I'm searching Name1 in Names and show all rows that are between first date and final date
Names : [Name1]
First date : [08.01.2012]
Final date : [09.30.2012]
[[SEARCH]]
Results will be:
+----+--------------+--------+----------+
| No | Names | ID | Date |
+----+--------------+--------+----------+
| 3 | Name1 |1136 |08.16.2012|
| 8 | Name1 |1296 |08.15.2012|
| 6 | Name1 |1836 |09.11.2012|
+----+--------------+--------+----------+
I don't know how to make this , can someone help me if he wouldn't mind?
Thank you, Jax
Upvotes: 0
Views: 3645
Reputation: 5380
select *
from your_table
where name='Name1' and Date between 'First date' and 'Final date';
Upvotes: 2
Reputation: 2548
Use this following query if datatype of First Date and Final Date is DateTime
SELECT
NO,Names,ID,Date
FROM
[Table Name]
WHERE
Names = 'Name1' AND
Date BETWEEN FirstDate AND SecondDate
If you are passing the First Date and Final Date as string , then you need to convert them to DATE data type and use in query as follows.
SELECT
NO,Names,ID,Date
FROM
[Table Name]
WHERE
Names = 'Name1' AND
CONVERT(DATE,[Date],101) BETWEEN CONVERT(DATE,FirstDate,101) AND
CONVERT(DATE,SecondDate,101)
Upvotes: 0
Reputation: 1211
you can use the sql query for solving this and the query is
select NO,Names,ID,Date from [your table] where Names='Name1' and Date Between FirstDate and SecondDate
Hope this will help you..
Upvotes: 1