计算2013年infopath中两个Datetime之间的时差 [英] Calculate time difference between two Datetime in infopath 2013
问题描述
大家好,
我是Infopath的新手。我需要帮助。
我有一个Infopath 2013表单,其中包含三个字段:
使用DateTime选择器的两个日期时间字段和第3个包含文本字段需要找到小时之间的差异
我如何能够区分两者,以便显示如下:
Date Time1:10/27/2015 05:59:53 PM
Date Time2 2:10/28/2015 05:59:56 PM
差异:1天,0小时,0分钟和3秒。
请帮我用自定义代码或不使用自定义代码获取此输出代码。
提前感谢您的回答
Hi All,
I'm new to Infopath. I need a help on it.
I have an Infopath 2013 form that contains three fields:
Two datetime field using DateTime picker and the 3rd contains the text field need to find the difference between in hours
How I can make the difference between the two so that the display will be like this:
Date Time1 : 10/27/2015 05:59:53 PM
Date Time2 2: 10/28/2015 05:59:56 PM
Difference : 1 days, 0 hours, 0 minutes and 3 seconds.
Please help me to get this output using custom code or without code.
Thank you in advance for your answer
推荐答案
减去两个DateTime的结果值产生TimeSpan值。
然后,您可以根据需要使用此TimeSpan。这样:
The result of the subtraction of two DateTime values yields a TimeSpan value.
You can then use this TimeSpan for your requirement. This way:
TimeSpan ts = Time2 - Time1;
string displayedResult = string.Format("{0} days, {1} hours, {2} minutes and {3} seconds", ts.Days, ts.Hours, ts.Minutes, ts.Seconds);
希望这会有所帮助。
Hope this helps.
这篇关于计算2013年infopath中两个Datetime之间的时差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!