Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Get Data between DateTime period from DataTable

Posted on 2012-12-29
2
Medium Priority
?
3,522 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

610 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