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

**URL:** <https://discuss.workflowgen.com/t/how-do-i-calculate-the-number-of-days-from-today-to-a-specified-date-on-my-web-form/158>\
**Category:** Visual Studio Web Forms\
**Created:** [May 19, 2008, 6:01am UTC](https://discuss.workflowgen.com/t/how-do-i-calculate-the-number-of-days-from-today-to-a-specified-date-on-my-web-form/158 "2008-05-19T06:01:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wfg-admin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.workflowgen.com/wfg-admin/32/714_2.png) [@wfg-admin](https://discuss.workflowgen.com/u/wfg-admin)\
**Post date:** [May 19, 2008, 6:01am UTC](https://discuss.workflowgen.com/t/how-do-i-calculate-the-number-of-days-from-today-to-a-specified-date-on-my-web-form/158/1 "2008-05-19T06:01:08Z")

</div>

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#

```auto
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](http://VB.NET)

```auto
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
