Difference between two 'Date and Time Picker' controls - InfoPath Dev
in

InfoPath Dev

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

Difference between two 'Date and Time Picker' controls

Last post 10-29-2012 03:02 AM by mohamad morshed. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 11-05-2011 07:40 AM

    Difference between two 'Date and Time Picker' controls

    Hello everyone,

    Im creating a web-enabled Infopath 2010 form which will be used to enter details of IT Support tickets. The form has two 'Date and Time Picker' controls:

    • TimeRaised
    • TimeRepaired

     I'd like the difference between these two fields to be displayed in a read-only text box titled TimeToResolve, so that admin can easily identify the most troublesome support tickets. I've found lots of resources covering Date Picker controls, however I cant find anything about calculating differences between two Date and Time Picker field?

    Can anyone help?

    Thanks!

    Nick

  • 11-05-2011 09:47 AM In reply to

    Re: Difference between two 'Date and Time Picker' controls

    Will both of the times always be within the same day?  If so, you can use this formula to get the number of minutes between two times:

    60 * (substring(laterTime, 12, 2) - substring(earlierTime, 12, 2)) + (substring(laterTime, 15, 2) - substring(earlierTime, 15, 2)) + (substring(laterTime, 18, 2) - substring(earlierTime, 18, 2)) div 60

     Is that sufficient for what you're looking for?

    Jimmy Rishe / Software Developer / InfoPath MVP
    Qdabra Software
  • 11-05-2011 10:00 AM In reply to

    Re: Difference between two 'Date and Time Picker' controls

    Hi Jimmy,

    Thanks for getting back to me. The difference between the two dates/times will vary condiserably, some forms might be returned within a couple of hours but others might take several days.

    Nick

     

  • 11-05-2011 10:53 AM In reply to

    Re: Difference between two 'Date and Time Picker' controls

    And are you looking for just a raw difference between two datetimes?  Do you need to take into account work hours, weekends and holidays?

    Jimmy Rishe / Software Developer / InfoPath MVP
    Qdabra Software
  • 11-05-2011 10:58 AM In reply to

    Re: Difference between two 'Date and Time Picker' controls

    Within business hours would be great but thats well beyond my Infopath knowledge so I hadnt even considered it!

    If you know how, then that would be awesome but I'm also happy with just raw differences.

  • 11-05-2011 11:18 AM In reply to

    Re: Difference between two 'Date and Time Picker' controls

    I hope I didn't get your hopes up too much because I don't know of a good way to account for business hours and holidays.  I was just making sure that wasn't a requirement.

    What you can do to get the raw difference is:

    1. Use the trick that's been floating around here to get the number of days between the two dates.
    2. Use my formula to get the difference between the two times (if the time on the start date is earlier in the day than the time on the end date, the result for this will be negative, but this is ok).
    3. Add 1 and 2 together (making sure to convert them to the same units first).

    That should give you the result you need.  I'll also point out that qRules provides an extremely simple command, DateDiff, for determining the difference between two datetimes, along with a whole lot of other cool stuff, and I recommend checking that out if you're looking to get more out of your InfoPath experience.

    Jimmy Rishe / Software Developer / InfoPath MVP
    Qdabra Software
  • 11-05-2011 11:27 AM In reply to

    Re: Difference between two 'Date and Time Picker' controls

    Thanks for your quick reply Jimmy,

    I've already got the date working so I just need to add your bit for the time. Looks like I might be making a few forms with dates as a central theme so I'll definitely look into qRules.

    Thanks again,

    Nick

  • 10-29-2012 03:02 AM In reply to

    Re: Difference between two 'Date and Time Picker' controls

     

    I used it, It was Really useful, Thanks a lot

     

    mohamad morshed
Page 1 of 1 (8 items)
Copyright © 2003-2012 Qdabra Software. All rights reserved.
View our Terms of Use.