Subtracting two DateTime fields - InfoPath Dev
in

InfoPath Dev

Subtracting two DateTime fields

Last post 11-25-2014 08:39 AM by Bre Huston. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 11-10-2014 12:48 PM

    Subtracting two DateTime fields

    So after many hours scouring the internet, I have been able to find both a date, and a time subtraction formula. I have been able to modify them as well, however, there are a few fatal flaws in this. For example, subtracting time alone cannot take into consideration for time spanning across multiple days (thus returning negative numbers if your timeend is before your timestart).

    What I am looking for is a way to subtract two DateTime fields without qRules or any type of code. I cannot use a SharePoint collumn to do this calc for me either, as the purpose of the form is primarily to submit to email. It also has to be done solely with Rules as below:

    StartTime = 10/11/2014 4:00 PM EndTime = 10/13/2014 9:00 AM

    Return = 1 Day 17 Hours

    If this is better to do in military time, I am happy to do that, but I am stuck!

    My primary source of info for this was: http://www.bizsupportonline.net/infopath2007/calculate-date-difference-infopath-rules-formulas.htm I have also used: http://www.bizsupportonline.net/infopath2003/time-calculations-infopath-using-rules.htm

    Thoughts? Comments? Thanks for your time and consideration!

    Filed under:
  • 11-25-2014 08:39 AM In reply to

    Re: Subtracting two DateTime fields

     Hello thelihyjr,

    You may want to look at trying to use an additional formula to subtract the dates. I would subtract date 2 from date 1 and then subtract one. In the formulat above, it would take 20141013 - 20141011 (2 days) minus 1 (an additional day) and return the days to a separate field from the hours. Out of the box this is probably going to be tricky, and a bit unreliable, especially if the dates span months.

    Another option would be to use qRules. There is a simple datediff command that easily calculates the difference between two dates in a desired format. Here's a link to more information about the command: http://www.infopathdev.com/forums/p/24353/84215.aspx#84215

    You can download a free trial of qRules here to try it out: http://www.qdabra.com/en/products/qRules_new.aspx

    Hope that helps!
    Bre

    Bre Huston | Project Manager

    Qdabra® Software / InfoPathDev.com / FormsQuo /  877.544.2389 main / 425.318.7843 direct

    Business Process Automation for Everyone – Streamline data gathering to turn process into knowledge.™


Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.