How to modify DataTable rows using Select() or LINQ

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
andre72Asked:
Who is Participating?
 
CodeCruiserCommented:
Try

mydt.Select("(StartTime >= NewStartTime AND StartTime <= NewEndTime) OR (EndTime >= NewStartTime AND EndTime <= NewEndTime)")
0
 
andre72Author Commented:
Thanks for your support
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.