{"id":154,"date":"2010-04-16T07:07:47","date_gmt":"2010-04-16T07:07:47","guid":{"rendered":"http:\/\/mahenderpal.wordpress.com\/?p=154"},"modified":"2018-08-16T00:13:21","modified_gmt":"2018-08-16T00:13:21","slug":"calculate-number-of-days-between-two-dates-in-ms-crm","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=154","title":{"rendered":"Calculate Number of Days between two Dates in MS CRM"},"content":{"rendered":"<p>Some time we need to calculate number of days between two dates in crm, we can easily do this using below JS script<\/p>\n<p>var d1=crmForm.all.FirstDate.DataValue;<br \/>\nvar d2=crmForm.all.SecondDate.DataValue;<br \/>\nvar DayValue=1000*60*60*24;<\/p>\n<p>alert(Math.ceil((d2.getTime()-d1.getTime())\/DayValue));<\/p>\n<p>Update for Dynamics 365<\/p>\n<p>var d1=Xrm.Page.getAttribute(&#8220;FirstDate&#8221;).getValue();<br \/>\nvar d2=Xrm.Page.getAttribute(&#8220;SecondDate&#8221;).getValue();<\/p>\n<p>var DayValue=1000*60*60*24;<\/p>\n<p>alert(Math.ceil((d2.getTime()-d1.getTime())\/DayValue));<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some time we need to calculate number of days between two dates in crm, we can easily do this using below JS script var d1=crmForm.all.FirstDate.DataValue; var d2=crmForm.all.SecondDate.DataValue; var DayValue=1000*60*60*24; alert(Math.ceil((d2.getTime()-d1.getTime())\/DayValue)); Update for Dynamics 365 var d1=Xrm.Page.getAttribute(&#8220;FirstDate&#8221;).getValue(); var d2=Xrm.Page.getAttribute(&#8220;SecondDate&#8221;).getValue(); var DayValue=1000*60*60*24; alert(Math.ceil((d2.getTime()-d1.getTime())\/DayValue));<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[402,522,24],"tags":[592,590,589,591,588],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/154"}],"collection":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=154"}],"version-history":[{"count":2,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/154\/revisions"}],"predecessor-version":[{"id":3203,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/154\/revisions\/3203"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}