Help please-Solve: Number of days = (todays date - date initiated) ???? - InfoPath Dev Sign in | Join | Help in General InfoPath (Entire Site) InfoPath Dev InfoPath Dev is dedicated to bringing you the information and tools you need to be successful in your Microsoft Office InfoPath development projects. Home Blogs Forums Photos Downloads InfoPath Dev » InfoPath » General » Help please-Solve: Number of days = (todays date - date initiated) ???? Use our Google Custom Search for best site search results. Help please-Solve: Number of days = (todays date - date initiated) ???? Last post 07-30-2018 07:57 AM by Travisty2520. 10 replies. Page 1 of 1 (11 items) Sort Posts: Oldest to newest Newest to oldest Previous Next 07-11-2012 04:47 AM earlkmi Joined on 07-11-2012 Posts 3 Help please-Solve: Number of days = (todays date - date initiated) ???? Reply Contact I can build this argument in excel: Column A = (C-B) 10 = (7/20/2012 - 7/10/2012) Column A is: Number of days Column B is: Date Initiated Column C is: Todays Date Can you please assist me with building this function in infopath thank you Filed under: math functions, Date Expression Display, functions 07-11-2012 06:24 AM In reply to ErnestoM Joined on 08-27-2007 Posts 3,320 Re: Help please-Solve: Number of days = (todays date - date initiated) ???? Mark as Not AnswerMark as Answer... Reply Contact Hi,Certain math, string and financial functions that are available in Excel are unfortunately not available in InfoPath. We resort to qRules when calculating date differences such as the one in your example above. Of course, custom code could also be used.Good luck! Ernesto MachadoQdabra® Software/ InfoPathDev.comThe InfoPath Experts – Streamline data gathering to turn process into knowledge.™ 07-11-2012 12:41 PM In reply to earlkmi Joined on 07-11-2012 Posts 3 Re: Help please-Solve: Number of days = (todays date - date initiated) ???? Mark as Not AnswerMark as Answer... Reply Contact Appreciate your help I was able to find a product that I used to resolve the "delta" = the difference between dates. The link is listed: http://www.bizsupportonline.net/infopath2007/calculate-date-difference-infopath-rules-formulas.htm Calculate the difference between two date picker controls in InfoPath using rules and formulas - no code! by S.Y.M. Wong-A-Ton | Applies to: InfoPath 2007 Use rules, conditions, and the number(), floor(), and substring() functions in formulas to calculate the difference between two date picker controls in InfoPath. Use rules, conditions, and the number(), floor(), and substring() functions in formulas to calculate the difference between two date picker controls in InfoPath. Problem You have a form template with two InfoPath date picker controls and you would like to calculate the difference between the two date picker controls without writing code. Solution Use rules, conditions, and the number(), floor(), and substring() functions in formulas to calculate the difference between two date picker controls in InfoPath. Discussion You can accomplish this functionality as follows: Design an InfoPath form template as shown in figure 1 with two Date Picker controls named startDate and endDate, and one Text Box control named difference. Figure 1. InfoPath form template in Design mode. The Main data source of the InfoPath form template should resemble the following figure: Figure 2. The Main data source of the InfoPath form template. Add the following Rule to the startDate field: Action: Set a field's value Field: difference Value: (number(substring(../my:endDate, 9, 2)) + floor((153 * (number(substring(../my:endDate, 6, 2)) + 12 * (floor((14 - number(substring(../my:endDate, 6, 2))) div 12)) - 3) + 2) div 5) + (number(substring(../my:endDate, 1, 4)) + 4800 - (floor((14 - number(substring(../my:endDate, 6, 2))) div 12))) * 365 + floor((number(substring(../my:endDate, 1, 4)) + 4800 - (floor((14 - number(substring(../my:endDate, 6, 2))) div 12))) div 4) - floor((number(substring(../my:endDate, 1, 4)) + 4800 - (floor((14 - number(substring(../my:endDate, 6, 2))) div 12))) div 100) + floor((number(substring(../my:endDate, 1, 4)) + 4800 - (floor((14 - number(substring(../my:endDate, 6, 2))) div 12))) div 400) - 32045) - (number(substring(., 9, 2)) + floor((153 * (number(substring(., 6, 2)) + 12 * (floor((14 - number(substring(., 6, 2))) div 12)) - 3) + 2) div 5) + (number(substring(., 1, 4)) + 4800 - (floor((14 - number(substring(., 6, 2))) div 12))) * 365 + floor((number(substring(., 1, 4)) + 4800 - (floor((14 - number(substring(., 6, 2))) div 12))) div 4) - floor((number(substring(., 1, 4)) + 4800 - (floor((14 - number(substring(., 6, 2))) div 12))) div 100) + floor((number(substring(., 1, 4)) + 4800 - (floor((14 - number(substring(., 6, 2))) div 12))) div 400) - 32045) with the following Conditions on the Rule: startDate is not blank and endDate is not blank Add a second Rule to the startDate field with the following settings: Action: Set a field's value Field: difference Value: 0 with the following Conditions on the Rule: startDate is blank or endDate is blank Add the following Rule to the endDate field: Action: Set a field's value Field: difference Value: (number(substring(., 9, 2)) + floor((153 * (number(substring(., 6, 2)) + 12 * (floor((14 - number(substring(., 6, 2))) div 12)) - 3) + 2) div 5) + (number(substring(., 1, 4)) + 4800 - (floor((14 - number(substring(., 6, 2))) div 12))) * 365 + floor((number(substring(., 1, 4)) + 4800 - (floor((14 - number(substring(., 6, 2))) div 12))) div 4) - floor((number(substring(., 1, 4)) + 4800 - (floor((14 - number(substring(., 6, 2))) div 12))) div 100) + floor((number(substring(., 1, 4)) + 4800 - (floor((14 - number(substring(., 6, 2))) div 12))) div 400) - 32045) - (number(substring(../my:startDate, 9, 2)) + floor((153 * (number(substring(../my:startDate, 6, 2)) + 12 * (floor((14 - number(substring(../my:startDate, 6, 2))) div 12)) - 3) + 2) div 5) + (number(substring(../my:startDate, 1, 4)) + 4800 - (floor((14 - number(substring(../my:startDate, 6, 2))) div 12))) * 365 + floor((number(substring(../my:startDate, 1, 4)) + 4800 - (floor((14 - number(substring(../my:startDate, 6, 2))) div 12))) div 4) - floor((number(substring(../my:startDate, 1, 4)) + 4800 - (floor((14 - number(substring(../my:startDate, 6, 2))) div 12))) div 100) + floor((number(substring(../my:startDate, 1, 4)) + 4800 - (floor((14 - number(substring(../my:startDate, 6, 2))) div 12))) div 400) - 32045) with the following Conditions on the Rule: startDate is not blank and endDate is not blank Add a second Rule to the endDate field with the following settings: Action: Set a field's value Field: difference Value: 0 with the following Conditions on the Rule: startDate is blank or endDate is blank Add the following Rule to the difference field: Action: Set a field's value Field: . Value: 0 with the following Condition on the Rule: difference does not match pattern Custom Pattern: -{0,1}\d+ You should now have a fully functional InfoPath form that will calculate the difference between the dates soon after you have entered valid dates. This solution also works for InfoPath 2003 form templates and InfoPath 2007 browser-enabled form templates. 03-03-2013 02:36 PM In reply to sengigi Joined on 03-01-2013 Posts 1 Re: Help please-Solve: Number of days = (todays date - date initiated) ???? Mark as Not AnswerMark as Answer... Reply Contact I have got a different scenario - I would like to point everything to 31/12/<year+1>. Example: if I select 03/04/2013, I would like the next date to return 31/12/2014. Any kind souls like to throw in suggestion 09-18-2013 01:29 PM In reply to jweller Joined on 09-18-2013 Posts 1 Re: Help please-Solve: Number of days = (todays date - date initiated) ???? Mark as Not AnswerMark as Answer... Reply Contact This works great, but how can one remove Saturday's and Sunday's from the calculations? Also, are there any tricks to including bank calendar holidays? Jason 03-26-2014 01:44 PM In reply to Judyy Joined on 03-25-2014 Posts 1 Re: Help please-Solve: Number of days = (todays date - date initiated) ???? Mark as Not AnswerMark as Answer... Reply Contact Will this solution work for InfoPath 2010? I have tried it with no luck :( Filed under: 2010 InfoPath 04-11-2014 12:12 AM In reply to magdalena.deleva Joined on 04-11-2014 Posts 5 Re: Help please-Solve: Number of days = (todays date - date initiated) ???? Mark as Not AnswerMark as Answer... Reply Contact Hi, when using this formula to calculate difference between dates, example 01/03/2013 to 03/03/2014 formula calculates 2 days, acctually difference is + days.Can you please advice where add +1 day in the formula or to change the logic of calculation?Thank you 07-12-2015 06:52 PM In reply to Michael Campbell Joined on 08-18-2008 Sydney Australia Posts 20 Re: Help please-Solve: Number of days = (todays date - date initiated) ???? Mark as Not AnswerMark as Answer... Reply Contact Thanks you. I am not a coder and this works perfrectly for me!!! 08-14-2015 07:21 AM In reply to Paul-Emile Joined on 05-15-2007 Posts 5 Re: Help please-Solve: Number of days = (todays date - date initiated) ???? Mark as Not AnswerMark as Answer... Reply Contact Hi, This code is working well until I pick dates that are in two different months. When I pick start date = 2015-08-01 and end date = 2015-09-05, it tells me that there are 4 days separating these dates while in fact there are 34. Any suggestions as how to fix this problem?Thanks 05-31-2018 10:29 AM In reply to InfoPathinator Joined on 05-31-2018 Posts 3 Re: Help please-Solve: Number of days = (todays date - date initiated) ???? Mark as Not AnswerMark as Answer... Reply Contact I utilize a separate SharePoint list to help calculate the number of days between two dates in Infopath. This is so I can account for leap years and have the ability to just count work days, not all days. I update this list with new data once a year.Here is the Excel file source for the list containing 2018-2020 data: https://1drv.ms/x/s!ApLhBloaS1wVgsUOMRrRfbekFftY9QSteps: Import the first worksheet of the above Excel file as a new list in SharePoint.Add a receive data connection to this list from your InfoPath form.For the first date, create a action to convert the date to a number in YYYYMMDD format. Assuming the date is stored as DateTime, you can use this formula: floor(number(translate(substring-before(../my:endDate, "T"), "-", "")))Query the list for the number value of the first date. Store this number in a field (column) in your form. (This field does not need to show in your form.)Repeat steps 3 & 4for the second date.Subtract the first date number from the 2nd, store this in a third column.Note: The Excel file uses the formula "NETWORKDAYS" and includes columns for weekdays, weekdays minus US Federal holidays, and weekdays minus NYSE holidays. Now you can get the number of work days between two dates using one of these columns. If you live outside the US, you could add a column to the Excel for other holidays, such as UK bank holidays. Dan Murphy 07-30-2018 07:57 AM In reply to Travisty2520 Joined on 07-30-2018 Posts 2 Re: Help please-Solve: Number of days = (todays date - date initiated) ???? Mark as Not AnswerMark as Answer... Reply Contact Hello, I am using two Date/Time fields to mark the start and end of a brake in out IT. I want the rules formulae to work out the difference between them as a mean time to repair for reporting currently using an spreadsheet but feel this is more progressive and can then add in other functions off this. Page 1 of 1 (11 items) Copyright © 2003-2019 Qdabra Software. All rights reserved.View our Terms of Use.
Use our Google Custom Search for best site search results.
I can build this argument in excel: Column A = (C-B) 10 = (7/20/2012 - 7/10/2012)
Column A is: Number of days
Column B is: Date Initiated
Column C is: Todays Date
Can you please assist me with building this function in infopath
thank you
Hi,
Certain math, string and financial functions that are available in Excel are unfortunately not available in InfoPath. We resort to qRules when calculating date differences such as the one in your example above. Of course, custom code could also be used.
Good luck!
Appreciate your help
I was able to find a product that I used to resolve the "delta" = the difference between dates.
The link is listed: http://www.bizsupportonline.net/infopath2007/calculate-date-difference-infopath-rules-formulas.htm
Calculate the difference between two date picker controls in InfoPath using rules and formulas - no code!
by S.Y.M. Wong-A-Ton | Applies to: InfoPath 2007
Use rules, conditions, and the number(), floor(), and substring() functions in formulas to calculate the difference between two date picker controls in InfoPath.
You have a form template with two InfoPath date picker controls and you would like to calculate the difference between the two date picker controls without writing code.
You can accomplish this functionality as follows:
(number(substring(../my:endDate, 9, 2)) + floor((153 * (number(substring(../my:endDate, 6, 2)) + 12 * (floor((14 - number(substring(../my:endDate, 6, 2))) div 12)) - 3) + 2) div 5) + (number(substring(../my:endDate, 1, 4)) + 4800 - (floor((14 - number(substring(../my:endDate, 6, 2))) div 12))) * 365 + floor((number(substring(../my:endDate, 1, 4)) + 4800 - (floor((14 - number(substring(../my:endDate, 6, 2))) div 12))) div 4) - floor((number(substring(../my:endDate, 1, 4)) + 4800 - (floor((14 - number(substring(../my:endDate, 6, 2))) div 12))) div 100) + floor((number(substring(../my:endDate, 1, 4)) + 4800 - (floor((14 - number(substring(../my:endDate, 6, 2))) div 12))) div 400) - 32045) - (number(substring(., 9, 2)) + floor((153 * (number(substring(., 6, 2)) + 12 * (floor((14 - number(substring(., 6, 2))) div 12)) - 3) + 2) div 5) + (number(substring(., 1, 4)) + 4800 - (floor((14 - number(substring(., 6, 2))) div 12))) * 365 + floor((number(substring(., 1, 4)) + 4800 - (floor((14 - number(substring(., 6, 2))) div 12))) div 4) - floor((number(substring(., 1, 4)) + 4800 - (floor((14 - number(substring(., 6, 2))) div 12))) div 100) + floor((number(substring(., 1, 4)) + 4800 - (floor((14 - number(substring(., 6, 2))) div 12))) div 400) - 32045)
(number(substring(., 9, 2)) + floor((153 * (number(substring(., 6, 2)) + 12 * (floor((14 - number(substring(., 6, 2))) div 12)) - 3) + 2) div 5) + (number(substring(., 1, 4)) + 4800 - (floor((14 - number(substring(., 6, 2))) div 12))) * 365 + floor((number(substring(., 1, 4)) + 4800 - (floor((14 - number(substring(., 6, 2))) div 12))) div 4) - floor((number(substring(., 1, 4)) + 4800 - (floor((14 - number(substring(., 6, 2))) div 12))) div 100) + floor((number(substring(., 1, 4)) + 4800 - (floor((14 - number(substring(., 6, 2))) div 12))) div 400) - 32045) - (number(substring(../my:startDate, 9, 2)) + floor((153 * (number(substring(../my:startDate, 6, 2)) + 12 * (floor((14 - number(substring(../my:startDate, 6, 2))) div 12)) - 3) + 2) div 5) + (number(substring(../my:startDate, 1, 4)) + 4800 - (floor((14 - number(substring(../my:startDate, 6, 2))) div 12))) * 365 + floor((number(substring(../my:startDate, 1, 4)) + 4800 - (floor((14 - number(substring(../my:startDate, 6, 2))) div 12))) div 4) - floor((number(substring(../my:startDate, 1, 4)) + 4800 - (floor((14 - number(substring(../my:startDate, 6, 2))) div 12))) div 100) + floor((number(substring(../my:startDate, 1, 4)) + 4800 - (floor((14 - number(substring(../my:startDate, 6, 2))) div 12))) div 400) - 32045)
You should now have a fully functional InfoPath form that will calculate the difference between the dates soon after you have entered valid dates. This solution also works for InfoPath 2003 form templates and InfoPath 2007 browser-enabled form templates.
I have got a different scenario - I would like to point everything to 31/12/<year+1>. Example: if I select 03/04/2013, I would like the next date to return 31/12/2014.
Any kind souls like to throw in suggestion
This works great, but how can one remove Saturday's and Sunday's from the calculations? Also, are there any tricks to including bank calendar holidays?
Jason
Hi, when using this formula to calculate difference between dates, example 01/03/2013 to 03/03/2014 formula calculates 2 days, acctually difference is + days.
Can you please advice where add +1 day in the formula or to change the logic of calculation?
Thank you
This code is working well until I pick dates that are in two different months. When I pick start date = 2015-08-01 and end date = 2015-09-05, it tells me that there are 4 days separating these dates while in fact there are 34. Any suggestions as how to fix this problem?
Thanks
I utilize a separate SharePoint list to help calculate the number of days between two dates in Infopath. This is so I can account for leap years and have the ability to just count work days, not all days. I update this list with new data once a year.Here is the Excel file source for the list containing 2018-2020 data: https://1drv.ms/x/s!ApLhBloaS1wVgsUOMRrRfbekFftY9QSteps:
Note: The Excel file uses the formula "NETWORKDAYS" and includes columns for weekdays, weekdays minus US Federal holidays, and weekdays minus NYSE holidays. Now you can get the number of work days between two dates using one of these columns. If you live outside the US, you could add a column to the Excel for other holidays, such as UK bank holidays.
Hello,
I am using two Date/Time fields to mark the start and end of a brake in out IT. I want the rules formulae to work out the difference between them as a mean time to repair for reporting currently using an spreadsheet but feel this is more progressive and can then add in other functions off this.