<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/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>Function to get the number of hours between two date and time</title><link>https://community.appian.com/discussions/f/user-interface/35572/function-to-get-the-number-of-hours-between-two-date-and-time</link><description>Hello All, 
 We need to calculate number of hours between two date and time values. and this should not consider weekends. 
 Thanks in advance</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Function to get the number of hours between two date and time</title><link>https://community.appian.com/thread/138705?ContentTypeID=1</link><pubDate>Fri, 26 Jul 2024 12:08:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:77fbecfa-d716-4715-9b4a-deb998c6dafb</guid><dc:creator>venkatrea696188</dc:creator><description>&lt;p&gt;If so , Use Stefan&amp;#39;s&amp;nbsp; logic ,but somehow you need to find out how many weekdays are there &lt;strong&gt;or&lt;/strong&gt; In default working calendar weekends are considered non working days , So use calworkingdays() .&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
local!workdays:calworkdays(ri!startTime,ri!endTime-1),
(hour(ri!endTime-ri!startTime)+local!workdays*24)
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Function to get the number of hours between two date and time</title><link>https://community.appian.com/thread/138701?ContentTypeID=1</link><pubDate>Fri, 26 Jul 2024 11:03:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6e21900b-ed0e-4f5f-bc7e-e8d14959aa95</guid><dc:creator>ak0642</dc:creator><description>&lt;p&gt;Thank you&amp;nbsp;&lt;a class="internal-link view-user-profile" href="/members/mathieud0001"&gt;Mathieu Drouin&lt;/a&gt;,&amp;nbsp; this considers only week hours. But my use case is only not to consider weekend hours.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Function to get the number of hours between two date and time</title><link>https://community.appian.com/thread/138700?ContentTypeID=1</link><pubDate>Fri, 26 Jul 2024 11:02:13 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c6dedeb8-5ae4-45a5-ab4a-b22433c00dd4</guid><dc:creator>ak0642</dc:creator><description>&lt;p&gt;Thank you Stephen. But it should not consider weekend hours.&lt;/p&gt;
&lt;p&gt;Eg: Start Date time :&amp;nbsp;07/26/2024 11:00AM&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; End Date time :&amp;nbsp;&lt;/span&gt;&lt;span&gt;07/29/2024 11:00AM&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;should give us 24 hours. It should ignore weekend hours.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Function to get the number of hours between two date and time</title><link>https://community.appian.com/thread/138699?ContentTypeID=1</link><pubDate>Fri, 26 Jul 2024 11:02:02 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:090e1222-7db7-40ad-a3f6-22a00b83fa28</guid><dc:creator>Mathieu Drouin</dc:creator><description>&lt;p&gt;You could&amp;nbsp;try using the calworkhours function.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.appian.com/suite/help/24.2/fnc_date_and_time_calworkhours.html"&gt;docs.appian.com/.../fnc_date_and_time_calworkhours.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Function to get the number of hours between two date</title><link>https://community.appian.com/thread/138696?ContentTypeID=1</link><pubDate>Fri, 26 Jul 2024 10:53:55 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:15516615-a8fb-44f1-b3a3-e564e6b0f015</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Just subtract the two dates. It will return an interval. That format is a bit weird, but you will find enough coding examples to parse it here.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!interval: split(userdatetime(2024,7,26,1,1,1) - userdatetime(2024,7,20,3,3,3), &amp;quot;:&amp;quot;),
  local!interval[1]*24 + local!interval[3]
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>