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: https://alecpojidaev.wordpress.com/2008/12/30/infopath-codeless-programming-walkthrough-2/
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”
I found that copying and pasting the julian formula at the link below for the start date and end date, then subtracting the 2 was much easier – you could add more info for years..fewer rules, etc.(from http://www.infopathdev.com/forums/p/30190/103288.aspx).
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.
Sorry Linda, I just noticed this comment. When you downloaded the form and opened in design mode, did the form work in preview mode?
Strange. If you google the text on the form it shows another author and the article is dated 2008. 😉
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.
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.
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?
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 🙁
Hi Eric, I just downloaded the form and published into a new form library. Worked like a charm, thanks for your post.
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?
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.