<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Calculating date and time differences in infoPath</title><link>https://www.infopathdev.com:443/forums/thread/75078.aspx</link><pubDate>Wed, 08 Feb 2012 00:58:52 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:75078</guid><dc:creator>traveladic</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/75078.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=75078</wfw:commentRss><description>I have a similar situation but I need to account for working hours, for example if the working hours are 7am to 5pm and job started on the 1-Jan-12 at 4pm and it was completed at 2-Jan-12 8am then the total should be 2hrs not 16hr.&amp;nbsp;and as some add fun there are weekends and holidays.</description></item><item><title>Re: Calculating date and time differences in infoPath</title><link>https://www.infopathdev.com:443/forums/thread/34333.aspx</link><pubDate>Mon, 17 Nov 2008 04:15:25 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:34333</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/34333.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=34333</wfw:commentRss><description>Code like this would do the trick.&amp;nbsp; Of course in actuality you would want to perform error checking first, to make sure that none of the input values is blank, and that endDateCombined occurs after startDateCombined. It would also make sense factor the &amp;quot;xsi:nil&amp;quot; removal code out into a separate method, since it&amp;#39;s used three times.&lt;font size="2"&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;blockquote&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; xsiNamespace = NamespaceManager.LookupNamespace(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;xsi&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;);&lt;br /&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;XPathNavigator&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; mdsNav = MainDataSource.CreateNavigator();&lt;br /&gt;&lt;/font&gt;&lt;font size="2"&gt;mdsNav.MoveToChild(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;myFields&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, NamespaceManager.LookupNamespace(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;my&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;));&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;DateTime&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; startDate = mdsNav.SelectSingleNode(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;my:startDate&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, NamespaceManager).ValueAsDateTime;&lt;br /&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;DateTime&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; startTime = mdsNav.SelectSingleNode(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;my:startTime&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, NamespaceManager).ValueAsDateTime;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;DateTime&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; endDate = mdsNav.SelectSingleNode(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;my:endDate&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, NamespaceManager).ValueAsDateTime;&lt;br /&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;DateTime&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; endTime = mdsNav.SelectSingleNode(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;my:endTime&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, NamespaceManager).ValueAsDateTime;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;DateTime&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; startDateCombined = startDate.Add(startTime.TimeOfDay);&lt;br /&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;DateTime&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; endDateCombined = endDate.Add(endTime.TimeOfDay);&lt;br /&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;TimeSpan&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; diff = endDateCombined.Subtract(startDateCombined);&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;XPathNavigator&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; nodeNav = mdsNav.SelectSingleNode(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;my:dayDiff&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, NamespaceManager);&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;if&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; (nodeNav.MoveToAttribute(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;nil&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, xsiNamespace))&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nodeNav.DeleteSelf();&lt;br /&gt;}&lt;br /&gt;nodeNav.SetValue(diff.Days.ToString());&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;font size="2"&gt;nodeNav = mdsNav.SelectSingleNode(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;my:hourDiff&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, NamespaceManager);&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;if&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; (nodeNav.MoveToAttribute(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;nil&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, xsiNamespace))&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nodeNav.DeleteSelf();&lt;br /&gt;}&lt;br /&gt;nodeNav.SetValue(diff.Hours.ToString());&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;nodeNav = mdsNav.SelectSingleNode(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;my:minuteDiff&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, NamespaceManager);&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;if&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; (nodeNav.MoveToAttribute(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;nil&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, xsiNamespace))&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nodeNav.DeleteSelf();&lt;br /&gt;}&lt;br /&gt;nodeNav.SetValue(diff.Minutes.ToString());&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;</description></item><item><title>Re: Calculating date and time differences in infoPath</title><link>https://www.infopathdev.com:443/forums/thread/34331.aspx</link><pubDate>Mon, 17 Nov 2008 02:21:01 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:34331</guid><dc:creator>kinecarg</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/34331.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=34331</wfw:commentRss><description>&lt;p&gt;Thank you. I went through the code, and this will be a great help. But the problem I am having is that I need the time between the days calculated, not just the days. For example, the application I am working on has a &amp;quot;Duration of Maintenance&amp;quot; field to calculate possible service outages. If a user enters a start date of 11/18/08 and an end date of 11/19/08 with a start&amp;nbsp;time related to the 11/18/08 date of 11:59 pm and an end time related to the end date of 11/19/08 of 3:00 am, I need the duration of maintenance field to auto fill with a duration of 3 hours and 1 minute. I can calculated the time, but not across days.&lt;/p&gt;
&lt;p&gt;Thanks again for your help.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Calculating date and time differences in infoPath</title><link>https://www.infopathdev.com:443/forums/thread/34309.aspx</link><pubDate>Sat, 15 Nov 2008 06:22:30 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:34309</guid><dc:creator>chandrakanth</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/34309.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=34309</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I hope it&amp;nbsp;helps you for solving your issue.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.bizsupportonline.net/infopath2007/calculate-date-difference-infopath-rules-formulas.htm"&gt;http://www.bizsupportonline.net/infopath2007/calculate-date-difference-infopath-rules-formulas.htm&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Calculating date and time differences in infoPath</title><link>https://www.infopathdev.com:443/forums/thread/34260.aspx</link><pubDate>Fri, 14 Nov 2008 03:59:52 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:34260</guid><dc:creator>sandhyapati</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/34260.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=34260</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Can you go through the below link.I hope it might help you&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.bizsupportonline.net/browserforms/calculate-date-difference-infopath-browser-form-c-sharp-code.htm"&gt;http://www.bizsupportonline.net/browserforms/calculate-date-difference-infopath-browser-form-c-sharp-code.htm&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Calculating date and time differences in infoPath</title><link>https://www.infopathdev.com:443/forums/thread/34246.aspx</link><pubDate>Thu, 13 Nov 2008 16:36:02 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:34246</guid><dc:creator>kinecarg</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/34246.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=34246</wfw:commentRss><description>&lt;p&gt;Hello -&lt;/p&gt;
&lt;p&gt;I have a browser based infopath form that I would like to have calculate the time that may or may not cross days. The article posted at:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.bizsupportonline.net/infopath2003/date-time-difference-calculations-vbscript.htm"&gt;http://www.bizsupportonline.net/infopath2003/date-time-difference-calculations-vbscript.htm&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;is exactly what I am looking for, but it is written in VBScript, InfoPath 2003, and I need a browser enabled form, InfoPath 2007. As an example, if the user enters the start date as 11/13/08 with a start time of 11:59 pm&lt;/p&gt;
&lt;p&gt;and an end time of 11/14/08 with an end time of 3:00 am, the time calculation should be 3&amp;nbsp; hours and 1 minute.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;</description></item></channel></rss>