Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everybody,
I have a datatable which contains 3 rows 'Project', 'Start Date' and 'End Date'. And I have two text boxes 'Min Days' and 'Max Days'. Now I have to filter the datatable so that I get the 'Project's which have a duration('Due Date' - 'Start Date') greater than 'Min Days' and less than 'Max Days'. I want to use the DataView.Rowfilter property. Please reply as soon as possible.

Thanks & Regards,
Srivikas.
Posted

use datediff http://www.w3schools.com/sql/func_datediff.asp[^]

logic is yours...
 
Share this answer
 
Let us say
dv is your dataview then you specify
dv.RowFilter = "(Date Difference) > Min Days and (Date Difference) < Max Days"

Hope this is helpful.
 
Share this answer
 
You must calculate date diff at procedure level follow this link

http://victoriayudin.com/2008/10/27/sql-server-how-to-get-date-differences/[^][]
C#
dv.RowFilter = "difference  > " minDays + " and " + "difference  < " + maxDays;


Question is why you are not using Linq?
Thanks
 
Share this answer
 
v3
Comments
Srivikas 18-Feb-13 7:24am    
Actually I am using this in a Sharepoint web part... How can I calculate the Duration in the rowfilter.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900