InfoPath – Difference between days

I had a request for a form to count the number of days between two date pickers as one of it’s functions.  All that you need to make this happen is add two date picker controls and one text field to display the count.  I have included an InfoPath sample form that explains this in detail and should provide you with the knowledge to add something like this to one of your forms.

I originally found this form on the following site when I faced this issue:

Alec Pojidaev has many great techniques for using no code solutions which I am a big fan of.  I suggest you check out his site to see all of the advanced features he has laid out.

Click the link below to download the zip file.


11 thoughts on “InfoPath – Difference between days

  1. I am unable to get this solution to work. I am able to enter the Start and End dates, however, the ‘dayDifference’ field is never displayed. I have double checked the formulas and rules and I’m at a loss.

    I know this post is over 2 years old, but any help would be greatly appreciated.

  2. Strange. If you google the text on the form it shows another author and the article is dated 2008. 😉

  3. Yeah, I originally published this a couple of years ago. After searching through many blogs, I came across a very good article from an InfoPath guru…. you 🙂

    I failed to link back to your site and I apologize for that. I have updated the posting to include a link back to your site.

  4. Hello Eric,

    Am new to InfoPath and found your solution. I followed your instructions but cannot get days difference. That is I cannot make work Daydifference for Main Rule and Finalize Rule. In the Field: field, your solution shows was appears to be a period or even a semicolon, that is not field but I cannot get that result and cannot type it in.

    As you likely know if no value in this field then the I cannot save the rule. Would appreciate your help to understand and fix.


  5. Ted, were you able to download the zipped file and preview the form? There are no fields named ‘Field’ in this solution. Could you possibly post a screenshot of your issue?

  6. Hi Erick, sadly no work for me, I need to generate 5 daydifferents camps and I change the camp’s names inside the formulas and did not work anymore 🙁

  7. Hi Eric, I just downloaded the form and published into a new form library. Worked like a charm, thanks for your post.

  8. Please I cannot publish this form to a SharePoint list. I can only publish to a SharePoint library which does not allow editing in infopath. How can I publish it to a sharepoint list please so I can edit?

  9. Stephen,

    InfoPath publishes to libraries by default so I’m not sure what issue you are having. If you download the form and open it in design mode, you should be able to work with it. If you want to use this as a list, it will not work that way. You will need to first create a custom list and add the fields. Then, convert the list to an InfoPath form.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.