[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Adding DateTime Values in a Calculated Column of Dataset

Posted on 2007-10-03
3
Medium Priority
?
456 Views
Last Modified: 2008-01-09
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.  
0
Comment
Question by:JimWarner
  • 2
3 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 20006767
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
0
 
LVL 35

Accepted Solution

by:
YZlat earned 2000 total points
ID: 20006775
actually if you need to subtract the integer from the Launch date, use

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, (-1) * Convert.ToDouble(dr("Lead Time")), dr("Launch Date"))
        Next
0
 
LVL 3

Author Comment

by:JimWarner
ID: 20007525
Perfect!  You're my hero.
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month18 days, 14 hours left to enroll

834 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