Solved

Get Data between DateTime period from DataTable

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Keyboard 2 41
Dynamics CRM Plugin Query TotalRecordCount returning -1 13 42
C# Formatting DateTime String Value 5 25
How to repeat the data 4 12
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

790 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