Click here to Skip to main content
12,621,744 members (36,350 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 18-Feb-13 1:52am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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

logic is yours...
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

You must calculate date diff at procedure level follow this link

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

Question is why you are not using Linq?
Thanks
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.161128.1 | Last Updated 18 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100