Subtracting time problems - InfoPath Dev
in

InfoPath Dev

Having trouble finding a blog or post that answers your question? Check out our Custom Search Page

Subtracting time problems

Last post 09-28-2010 09:11 PM by Jimmy. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 09-28-2010 05:41 AM

    Subtracting time problems

    Hi guys, I'm trying to figure out a way to subtract a constant time value (7.21) from another time value (a Whole Number field that's populated by using substring before's on actual time fields). The problem is when trying to subtract the .21 from a value that's lower than .21 and getting a minus value, instead of subtracting from the hours. Can anybody help me with a formula that could fix this?
  • 09-28-2010 06:24 AM In reply to

    Re: Subtracting time problems

    Use addSeconds(timeField, -75600).  Here 75600 is the result of 60 * (21 + (60 * 7)).  To use this formula, you should leave the time field with its colons in it, and not extract them out.

    Jimmy Rishe / Software Developer / InfoPath MVP
    Qdabra Software
  • 09-28-2010 06:02 PM In reply to

    Re: Subtracting time problems

    The only problem is that the field I need to subtract from isn't a time field. I'm using substring-before to subtract the hours and minutes of each time field into separate Whole Number fields, finding the highest of each and subtracting them, then concatenating them into another field to look like a time field. It doesn't look like addSeconds works on anything but timefields? Not sure if the way I'm doing it is overly complicated. I can upload a copy (it's in the very early stages) if you want to see what I mean?
  • 09-28-2010 06:54 PM In reply to

    Re: Subtracting time problems

    Yes, that would certainly be helpful in illuminating what you mean.

    Jimmy Rishe / Software Developer / InfoPath MVP
    Qdabra Software
  • 09-28-2010 07:22 PM In reply to

    Re: Subtracting time problems

    It's got two views, one for the user to actually see and the other is where it's performing the calculations. The time worked field is where it needs to subtract the 7.21 hours. I've actually got another form that's practically finished but the formatting stuffs up if the make the minutes lower. (bah, i'll zip them both together, but it's probably a bit confusing the follow - you can tell I'm new!). If you could help me with this one it'd probably be much easier? The way I'm doing this one is converting the time to seconds, and then back to decimal (I think you even helped me with one of the formulas?) The one I'm referencing with this thread is the file named TEST1. The one that's practically finished but the formatting breaks is the one called Flex1. http://filevo.com/o4dhuxmzun3t.html I really can't thank you enough for your help! Cheers mate. (Also, how do you do paragraphs on this forum? I know nobody likes a wall of text)
  • 09-28-2010 07:59 PM In reply to

    Please have a look at the attached form.  I used a different default value formula on monLarge that doesn't require the separate calculation fields.

    I'd also point out that your monMins and monMinf fields were not actually in the Calculations group, but were actually underneath the root node, with all the other fields.  Just something to look out for.

    Jimmy Rishe / Software Developer / InfoPath MVP
    Qdabra Software
  • 09-28-2010 09:08 PM In reply to

    Re: Subtracting time problems

    Thanks for the help Jimmy, but I still can't figure out how to subtract 7.21 from the monTotal field?
  • 09-28-2010 09:11 PM In reply to

    Re: Subtracting time problems

    I can show you how to do that, but is 7.21, 7 hours and 21 minutes, or is it 7.21 hours?  I'm confused by your use of a period here.

    Jimmy Rishe / Software Developer / InfoPath MVP
    Qdabra Software
Page 1 of 1 (8 items)
Copyright © 2003-2012 Qdabra Software. All rights reserved.
View our Terms of Use.