WorkflowGen.com | Knowledge Base | Documentation | Downloads | Support | RSS

« How do we get FireFox to use Integrated Authentication the way IE does? | Main | Is it possible to have multiple processes each starting at request #1? »

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

Posted on Sunday, May 18, 2008 at 15:01 by Registered CommenterWFG Team in | CommentsPost a Comment

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 slected date 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.Today
Dim 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

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.
Member Account Required
You must have a member account on this website in order to post comments. Log in to your account to enable posting.