Time Calculations - InfoPath Dev
in

InfoPath Dev

Time Calculations

Last post 02-20-2007 06:30 AM by Matt Faus. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 01-23-2007 02:51 PM

    Time Calculations

    OK, I have been searching high an low to figure out a way to do this without using managed code. I think the only way to this is with scripting or coding. I think I would prefer to use jscript if possible... as i hae some other jscript in place already...

    I have 5 fields: StartTime, ReportTime, EndTime, OutageDuration, & MTTR (Mean Time To Repair)

    What I need to do is end up with two values. Outage Duration needs to be HH:MM = EndTime - StartTime and MTTR needs to be (EndTime - ReportedTime) in minutes/60.

    I need to have the Start Time and Report Time and End Time be in mm/dd/yy hh/mm format ...

    any ideas. I have been looking high an low. I have not had very much luck.
  • 01-24-2007 12:06 AM In reply to

    Hi
    Check this link,Hope this helps you!
    http://enterprise-solutions.swits.net/infopath2003/article.php?t=time-calculations-using-rules&c=infopath2003

    And for your second question, You want to enter the date and time manually or by using the date picker?
    Shilpa
    INFOPATHDEV India
  • 01-25-2007 12:05 PM In reply to

    Thank you, this does work, but only if dealing with time whick limits me to a 24 hour period. I need to be able to calculate date and time... some times start on one day but end on the next day...
  • 02-16-2007 12:19 PM In reply to

    • DuneBug
    • Not Ranked
    • Joined on 12-14-2006
    • USA
    • Posts 6
    you may've already thought of this, and i'm not sure what environment you're using, but do you know about the system.Datetime object?

    As long as you're working with Microsoft I'd think you'd have it available to you. Here's a link with some documentation on it.

    If you have to do math with dates and times using a pre-made object is the only way to do it.


    http://msdn2.microsoft.com/en-us/library/system.datetime.aspx
  • 02-20-2007 06:30 AM In reply to

    DuneBug is exactly right on this one. You will want to do something like this:

    DateTime startTime = DateTime.Parse( stringValueOfStartTimeField );
    DateTime endTime = DateTime.Parse( stringValueOfEndTimeField );

    TimeSpan duration = endTime.Subtract( startTime );
    string output = duration.Hours + ":" + duration.Minutes; // Assumes < 24 hours, also probably want to add zero padding
    // same thing for mttr


    This has been discussed several times on the forum so you might want to do a quick search if you run into trouble.
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.