Solved

Get Data between DateTime period from DataTable

Posted on 2012-12-29
2
3,304 Views
Last Modified: 2012-12-31
Hi Experts,

I am working on ASP.net4.0 using C#

I have a DataTable having column "Creation Date", which is of DateTime type

Now I have advance search option where user can select from date and To date in dd/MM/yyyy format (i.e., 29//12/2012)

From my datatable I want to select data from my DataTable, based on from and to creatation date.

If I have to find data based on string I do as below:
dt2.Select("Owner = 'XYZ'");

where dt2 is my DataTable.

Please help me to add another from and to date criteria in my above query, so that query should look like something

string fromDate = "10/12/2012";
string fromDate = "20/12/2012";

In DataTable I have column "Creation Date" of DateTime type

dt2.Select("Owner = 'XYZ' AND (COMPARE DATE HERE)");

Please suggest
0
Comment
Question by:tia_kamakshi
2 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 38729532
Use hash marks ( # ) to encapsulate your date literals.

e.g.

dt2.Select("Owner = 'XYZ' AND dateColumn < #12/29/2012#");

Open in new window


http://www.csharp-examples.net/dataview-rowfilter/
0
 

Author Closing Comment

by:tia_kamakshi
ID: 38732534
Many Thanks for your help
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now