TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Shakir Ali
NA
359
1.6k
How to search in datatable by datetime
Dec 14 2018 10:13 PM
Hello Everyone,
I have a DataTable that contains three columns ID, Shift Start and Shift End. I want to search all records in given date time suppose i want to search by "4/12/2018 22:53". I tried the following code but not working.
// Presuming the DataTable has a column named Date.
string expression;
expression = "[Shift Start] >= #4/12/2018 10:53:00 PM# AND [Shift End] <= #4/12/2018 10:53:00 PM#";
DataRow[] foundRows;
// Use the Select method to find all rows matching the filter.
foundRows = dt.Select(expression);
// Print column 0 of each returned row.
for (int i = 0; i < foundRows.Length; i++)
{
MessageBox.Show(foundRows[i][1].ToString());
}
Sample DataTable
Thanks in advance.
Reply
Answers (
1
)
nested if's statements
declaring a method