[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Get Data between DateTime period from DataTable

Posted on 2012-12-29
2
Medium Priority
?
3,573 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 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

834 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