<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Get number of days between createdate &amp;amp; closedate of a deal in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Get-number-of-days-between-createdate-amp-closedate-of-a-deal/m-p/692495#M56887</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/438810"&gt;@S_Tasneem&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On the first try you do get a timestamp, you simply have to substract both timestamps (create date - today or vice versa) and convert the result back in days.&lt;/P&gt;
&lt;P&gt;A timestamp is usually in milliseconds, so to get the number of days you could use this simple formula :&lt;/P&gt;
&lt;P&gt;result_in_days = result_in_ms/1000/60/60/24 and truncate that to the day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a working snippet I've just tested :&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;var date = event.inputFields['createdate'];  
var future_date = Date.now();
  
var days_difference = Math.abs(Math.trunc((future_date - date)/(1000*3600*24)));&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LMeert_0-1663057662524.png" style="width: 999px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/74828i266C0A9D4F4A2C23/image-size/large?v=v2&amp;amp;px=999" role="button" title="LMeert_0-1663057662524.png" alt="LMeert_0-1663057662524.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps !&lt;BR /&gt;If it does, please consider marking this answer as a solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;Ludwig&lt;/P&gt;</description>
    <pubDate>Tue, 13 Sep 2022 08:28:43 GMT</pubDate>
    <dc:creator>LMeert</dc:creator>
    <dc:date>2022-09-13T08:28:43Z</dc:date>
    <item>
      <title>Get number of days between createdate &amp; closedate of a deal</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Get-number-of-days-between-createdate-amp-closedate-of-a-deal/m-p/690709#M56820</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;My requirement is to get the number of days-difference between cretedate &amp;amp; closedate of a deal. The number of days between these two dates should be populated in a third-party application form, So I am doing the development in a deal-based workflow. But I am not able to get the correct date format of the two dates, So I am not able to get the days-difference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try1: I have passed this line of code in workflow:&lt;/P&gt;&lt;P&gt;var create_date = event.inputFields['createdate']&lt;/P&gt;&lt;P&gt;but the value returned is&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S_Tasneem_0-1662619255420.png" style="width: 284px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/74533iF107CFCB54359DDC/image-dimensions/284x18?v=v2" width="284" height="18" role="button" title="S_Tasneem_0-1662619255420.png" alt="S_Tasneem_0-1662619255420.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Try2: I tried changing the code to:&lt;/P&gt;&lt;P&gt;var create_date = new Date(event.inputFields['createdate'])&lt;/P&gt;&lt;P&gt;but the value returned is&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S_Tasneem_1-1662619390735.png" style="width: 269px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/74534iAE4414472AEE1B09/image-dimensions/269x21?v=v2" width="269" height="21" role="button" title="S_Tasneem_1-1662619390735.png" alt="S_Tasneem_1-1662619390735.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Any suggestions would be greatly helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thankyou!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 06:46:35 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Get-number-of-days-between-createdate-amp-closedate-of-a-deal/m-p/690709#M56820</guid>
      <dc:creator>S_Tasneem</dc:creator>
      <dc:date>2022-09-08T06:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: Get number of days between createdate &amp; closedate of a deal</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Get-number-of-days-between-createdate-amp-closedate-of-a-deal/m-p/692170#M56855</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/438810"&gt;@S_Tasneem&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt; Let's see if we can get the converstaion going with some of our community experts.&lt;/P&gt;
&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/101258"&gt;@Teun&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/257487"&gt;@LMeert&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/642"&gt;@mangelet&lt;/a&gt;, do&amp;nbsp;you have any insight you can offer to&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/438810"&gt;@S_Tasneem&lt;/a&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you! — Jaycee&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 17:32:43 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Get-number-of-days-between-createdate-amp-closedate-of-a-deal/m-p/692170#M56855</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2022-09-12T17:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: Get number of days between createdate &amp; closedate of a deal</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Get-number-of-days-between-createdate-amp-closedate-of-a-deal/m-p/692495#M56887</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/438810"&gt;@S_Tasneem&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On the first try you do get a timestamp, you simply have to substract both timestamps (create date - today or vice versa) and convert the result back in days.&lt;/P&gt;
&lt;P&gt;A timestamp is usually in milliseconds, so to get the number of days you could use this simple formula :&lt;/P&gt;
&lt;P&gt;result_in_days = result_in_ms/1000/60/60/24 and truncate that to the day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a working snippet I've just tested :&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;var date = event.inputFields['createdate'];  
var future_date = Date.now();
  
var days_difference = Math.abs(Math.trunc((future_date - date)/(1000*3600*24)));&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LMeert_0-1663057662524.png" style="width: 999px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/74828i266C0A9D4F4A2C23/image-size/large?v=v2&amp;amp;px=999" role="button" title="LMeert_0-1663057662524.png" alt="LMeert_0-1663057662524.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps !&lt;BR /&gt;If it does, please consider marking this answer as a solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;Ludwig&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 08:28:43 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Get-number-of-days-between-createdate-amp-closedate-of-a-deal/m-p/692495#M56887</guid>
      <dc:creator>LMeert</dc:creator>
      <dc:date>2022-09-13T08:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: Get number of days between createdate &amp; closedate of a deal</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Get-number-of-days-between-createdate-amp-closedate-of-a-deal/m-p/1015026#M75258</link>
      <description>&lt;P&gt;Hi there, we have built an app for the marketplace that allows you to automatically calculate the time between 2 dates. Feel free to check it out here:&amp;nbsp;&lt;A href="https://ecosystem.hubspot.com/marketplace/apps/marketing/data-management/calculations-3449553" target="_blank"&gt;https://ecosystem.hubspot.com/marketplace/apps/marketing/data-management/calculations-3449553&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 00:41:03 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Get-number-of-days-between-createdate-amp-closedate-of-a-deal/m-p/1015026#M75258</guid>
      <dc:creator>Thrive</dc:creator>
      <dc:date>2024-07-24T00:41:03Z</dc:date>
    </item>
  </channel>
</rss>

