Solved

Get Data between DateTime period from DataTable

Posted on 2012-12-29
2
3,271 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 74

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

747 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

12 Experts available now in Live!

Get 1:1 Help Now