Link to home
Start Free TrialLog in
Avatar of JimWarner
JimWarnerFlag for United States of America

asked on

Adding DateTime Values in a Calculated Column of Dataset

I am trying to add a calculated  "Due Date" column to a dataset using the expression property, but I am having trouble with the syntax.  Due date needs to be calculated by subtracting a "Lead Time" field from a "Launch Date" field - both of which are on the same row as Due Date.  The root problem is that the lead time is an integer and the launch date is a DateTime, so I can't simply add them.   I'd expect to be able to use the AddDays method of a DateTime to easily add them together, but I can't figure out how to use the method within the Expression syntax.

If this tack won't work, I am open to other ideas to accomplish the goal of producing that Due Date column.  
Avatar of YZlat
YZlat
Flag of United States of America image

ds.Tables(0).Columns.Add(New DataColumn("Due Date"))

        For Each dr As DataRow In ds.Tables(0).Rows
            dr("Due Date") = DateAdd(DateInterval.Day, Convert.ToDouble(dr("Lead Time")), dr("Launch Date"))
        Next
ASKER CERTIFIED SOLUTION
Avatar of YZlat
YZlat
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JimWarner

ASKER

Perfect!  You're my hero.