How do I calculate the number of days from Today to a specified date on my web form?

Problem

I need a function that takes a date input (using the eWorld Calandar control)on a web form and calculates the number of days from today to that slecteddate and puts it into a field that I can then use as an OUT parameter. I need this for a lead time…

Solution

To use a calculated amount of time as an actions Lead Time, you will need to add the following code before the form is submitted to WorkflowGen (i.e.: within the submit button’s click event):

C#

DateTime FromTime = DateTime.Today;
DateTime ToTime = MY_DATE_PICKER.SelectedDate;
TimeSpan DateDiff = ToTime - FromTime;
int TheLeadTime = DateDiff.Minutes;
this.MY_OUT_TEXTBOX_FOR_LEADTIMES.Text = TheLeadTime;

VB.NET

Dim FromTime As DateTime = DateTime.TodayDim ToTime As DateTime = MY_DATE_PICKER.SelectedDate
Dim DateDiff As TimeSpan = (ToTime - FromTime)
Dim TheLeadTime As Integer = DateDiff.Minutes
Me.MY_OUT_TEXTBOX_FOR_LEADTIMES.Text = TheLeadTime

You may want to add some validation such as checking if ToTime is always > FromTime