We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

How to modify DataTable rows using Select() or LINQ

Medium Priority
486 Views
Last Modified: 2013-12-16
Hi,

I've a DataTable with some tasks an starttime and endtime like this:
Action            StartTime      EndTime
Sleep            9:04            9:54
Breakfast              9:54            10:31
Go to work      10:31      11:07

Now I need to modify the rows if I need entries to insert, e.g. shower from 9:41 to 10:08 :

Action            StartTime      EndTime
Sleep            9:04            9:41
Shower           9:41         10:08
Breakfast              10:08      10:31
Go to work      10:31      11:07

Till now I had a MDB as backend so I get the rows by a SQL command like:
SELECT * FROM table WHERE (StartTime BETWEEN NewStartTime AND NewEndTime) OR (EndTime BETWEEN NewStartTime AND NewEndTime)

With the rows returned by the query I do a lot of string operations to compare what I've to change / update / insert and store these results back to my MDB.

The matter is that I've no more a backend so I've to do these operations in memory now...

So would to you think is a way to do so, I tried mydt.Select("(StartTime BETWEEN NewStartTime AND NewEndTime) OR (EndTime BETWEEN NewStartTime AND NewEndTime)") reports an error for BETWEEN so I think I can't use it - or do I something wrong?

Oris there a simple way you use with LinQ?
As I'm a novice with LinQ I may need some useful hints for how to do something like tis ...

Thanks

Andre
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Mohamed AbowardaSenior Software Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
Thanks for your support
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.