Adding (summing) clock time - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Adding (summing) clock time

Last post 10-24-2012 12:22 PM by workin'stiff. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 10-03-2012 12:47 PM

    Adding (summing) clock time

    I'm trying to find a no code solution for the following problem.

    I've got a text field (formatted as time with the following format, XX:XX). I need to add a defined amount of time to the previously referenced text field. The returned value needs to be formatted in XX:XX.

    Any help with this would be greatly appreciated. And let me know if I've overlooked any details.

    Thanks!

  • 10-11-2012 03:31 PM In reply to

    Re: Adding (summing) clock time

    You can use rules to create this effect, though it may get a little complicated.  You can use string functions (substring) in InfoPath to parse our the hour and the minutes.  Then you can add to the minutes based on the total amount then divide by 60.  The result should be added to the hours and then the remainder should be added to the minutes.  Lastly you can use concat() to combine the hour and minutes together for the return value.  Hope that makes sense.  Let me know if you need more specifics on how to accomplish this.
    Anson Hidajat
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™

  • 10-23-2012 09:34 AM In reply to

    Re: Adding (summing) clock time

    Anson Hidajat:
    You can use rules to create this effect, though it may get a little complicated.  You can use string functions (substring) in InfoPath to parse our the hour and the minutes.  Then you can add to the minutes based on the total amount then divide by 60.  The result should be added to the hours and then the remainder should be added to the minutes.  Lastly you can use concat() to combine the hour and minutes together for the return value.  Hope that makes sense.  Let me know if you need more specifics on how to accomplish this.

    Anson,

    Thanks for your insight with this. I was fortunate enough to have the IT department just upgrade my computer to IP 2010. With the addSeconds feature, is it possible to now add two time fields togother with this function? I know the standard syntax is addSeconds(field, seconds). But I would like to accomplish addSeconds(field1, field2).

    Thanks!

  • 10-23-2012 09:57 AM In reply to

    Re: Adding (summing) clock time

    You should be able to use a field for the seconds parameter.  Let me know if that doesn't work for you.
    Anson Hidajat
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™

  • 10-23-2012 11:03 AM In reply to

    Re: Adding (summing) clock time

    It appears that IP doesn't like two field parameters. When I enter values into the preview, it comes up with ERR? in the resultant field. Yet in the formula editor, there are no errors found when running the check... Strange...

  • 10-23-2012 11:11 AM In reply to

    Re: Adding (summing) clock time

    What are you entering as your second field?  It has to be in seconds format so likely an integer.  You cannot put something else like a time field.
    Anson Hidajat
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™

  • 10-23-2012 02:22 PM In reply to

    Re: Adding (summing) clock time

    Ah, thats my issue! Thanks!

  • 10-23-2012 02:28 PM In reply to

    Re: Adding (summing) clock time

    I'm now having a strange issue where the resultant of the addSeconds is adding an additional 5 hours to every computation. For instance, I have the following formula: addSeconds(field1, 1800). Field1 = 12:15. The resultant should be 12:45. Instead, I'm getting 17:45. All of my formatting is correct, from what I can tell... But I'm definitely pulling my hair out over this...

  • 10-23-2012 03:02 PM In reply to

    Re: Adding (summing) clock time

    It looks like the addSeconds function adds the seconds correctly but is removing the time zone stamp from the date which is why you get the addition of 5 hours. Did a quick search and couldn't find a reason why it does this or a good workaround.  But if you know you're always going to be in the -5GMT zone, you could simply add a "-5:00" to the end of the XML value.
    Anson Hidajat
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™

  • 10-24-2012 12:22 PM In reply to

    Re: Adding (summing) clock time

    Would you go through an XML editor to hard code this?

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