Working out time difference between two fields. - InfoPath Dev

InfoPath Dev

Use our Google Custom Search for best site search results.

Working out time difference between two fields.

Last post 07-30-2018 08:08 AM by Travisty2520. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 03-03-2013 11:45 AM

    • Zeb Ahmed
    • Not Ranked
    • Joined on 03-03-2013
    • Auckland, New Zealand
    • Posts 4

    Working out time difference between two fields.

    Hello all, I have three fields in a form:


    I'm trying to calculate in the Duration field the time difference between the times entered in StartTime and EndTime.

    e.g. If StartTime is 15:00 and EndTime is 15:30 the Duration field should populate with 00:30

    Except I can't figure out how to do this, and the one link I found on here:

    KINDA works, but for some reason puts a horrid red bold dotted line around the Duration field. I don't know why it's doing this because there are no rules on that field that would cause this.


    I've tried several guides but can't figure it out.. really the above link was the closest to working for me, except for that horrid red dotted line.

    This confused the *beep!* out of me :( 

    This made sense as it was step by step, but it was written for InfoPath 2003, and even after giving it a go, it did not work. 

    I tried to use the following formulates but InfoPath errored on them: 
    (with the columns matching the names of my columns; formula applied to the field (default value) that will display the difference) 
    Found on this page: 

    I'd just like to find a step by step guide that shows me how to do this. Help? :)

  • 03-10-2013 11:52 AM In reply to

    Re: Working out time difference between two fields.

    The horrid red bold dotted line is because the field is a date-time when you just want time. Double click the fields in the taskpane and change from date-time to just time.

    You should be able to just remove the colon from the time using translate(field,":","") and then subtract one from the other. So, if field1 and field2 are time formats and you want field3 to be the difference (where field3 is a number). Just double click field3 and add a default value that is something like this: translate(../my:field2, ":", "") - translate(../my:field1, ":", "").

    Patrick Halstead
    Project Manager at Qdabra
  • 07-30-2018 08:08 AM In reply to

    Re: Working out time difference between two fields.

     Hello Patrick,

     How do I do this if I need them to be Date/Time fields as the errors last over several days I also need it to exclude weekends if possible

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