<?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 How do you calculate number of days between two dates? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-you-calculate-number-of-days-between-two-dates/m-p/13978#M13117</link>
    <description>&lt;P&gt;If I have two date fields, both with m/d/y width 12 formats, how do I get the difference in number of days? Is there an easy way to do this?&lt;/P&gt;</description>
    <pubDate>Thu, 31 Aug 2017 09:10:35 GMT</pubDate>
    <dc:creator>goutam</dc:creator>
    <dc:date>2017-08-31T09:10:35Z</dc:date>
    <item>
      <title>How do you calculate number of days between two dates?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-you-calculate-number-of-days-between-two-dates/m-p/13978#M13117</link>
      <description>&lt;P&gt;If I have two date fields, both with m/d/y width 12 formats, how do I get the difference in number of days? Is there an easy way to do this?&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 09:10:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-you-calculate-number-of-days-between-two-dates/m-p/13978#M13117</guid>
      <dc:creator>goutam</dc:creator>
      <dc:date>2017-08-31T09:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: how do you calculate number of days between two dates?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-you-calculate-number-of-days-between-two-dates/m-p/13979#M13118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Goutam,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the question!&lt;/P&gt;&lt;P&gt;To get the difference in days between two dates in JMP (in D/M/Y format), you can easily do the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Easiest Way: Delta (Days)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Step 1: Create a new column in your data table &lt;/P&gt;&lt;P&gt;Step 2: Subtract the first date from the second date and&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;divide this by 86,400&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;JMP returns the date difference in seconds, so 86,400 is the total seconds in a day to get this convereted into a count of days.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5em; font-size: 10pt;"&gt;See below for the &lt;/SPAN&gt;formula.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="9640_Screen Shot 2015-08-23 at 7.15.46 AM.png" style="width: 1438px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/2094i2527083B9484DEDD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="9640_Screen Shot 2015-08-23 at 7.15.46 AM.png" alt="9640_Screen Shot 2015-08-23 at 7.15.46 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;AlternativeWay: Delta (D:H:M) Time Duration&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Step 1: Create a formula in a new column in your data table&lt;/P&gt;&lt;P&gt;Step 2: Just subtract the first date from the second date&lt;/P&gt;&lt;P&gt;Step 3: In the column properties, under format, select Duration day:hr:m from the drop down list&lt;/P&gt;&lt;P&gt;This will return the difference in day count, plus any remaining hours and minutes.&lt;/P&gt;&lt;P&gt;See below for the formula and format:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="9642_Screen Shot 2015-08-23 at 7.25.47 AM.png" style="width: 1153px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/2095iEBBE39F8635B30B7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="9642_Screen Shot 2015-08-23 at 7.25.47 AM.png" alt="9642_Screen Shot 2015-08-23 at 7.25.47 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2016 00:27:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-you-calculate-number-of-days-between-two-dates/m-p/13979#M13118</guid>
      <dc:creator>scwise</dc:creator>
      <dc:date>2016-10-19T00:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: how do you calculate number of days between two dates?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-you-calculate-number-of-days-between-two-dates/m-p/13980#M13119</link>
      <description>&lt;P&gt;&lt;A href="https://community.jmp.com/t5/JMPer-Cable/Using-dates-times-datetimes-and-durations-in-JMP/ba-p/68689" target="_blank" rel="noopener"&gt;Date values are stored&lt;/A&gt; internally as the number of seconds lapsed from a reference date (January 1, 1904). Hence, the difference between two dates in &lt;EM&gt;days&lt;/EM&gt; can be calculated by:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;(:Date2 - :Date1) / (60 * 60 * 24)&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;There is also a function &lt;A href="https://www.jmp.com/support/help/en/15.1/#page/jmp/date-and-time-functions.shtml#ww2538966" target="_self"&gt;&lt;EM&gt;Date Difference()&lt;/EM&gt;&lt;/A&gt; in JMP 12 (may have been there in earlier versions too, I didn't notice it until now). It does the same thing as far as I can tell, but it has some nice options (look them up the Scripting Index, Help Menu).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Date Difference(:Date1, :Date2, "Day")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 13:58:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-you-calculate-number-of-days-between-two-dates/m-p/13980#M13119</guid>
      <dc:creator>ms</dc:creator>
      <dc:date>2020-05-18T13:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: how do you calculate number of days between two dates?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-you-calculate-number-of-days-between-two-dates/m-p/13981#M13120</link>
      <description>&lt;P&gt;Hi Goutam,&lt;/P&gt;
&lt;P&gt;there is a designated formula just for that. it is called Date difference and you can find it in the formula editor under&amp;nbsp; "Date Time" functions.&lt;/P&gt;
&lt;P&gt;the following is from the help files:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="HeadMinor"&gt;Date Difference&lt;/P&gt;
&lt;P class="HeadMinor"&gt;Returns the difference of two datetime values. The interval argument can be Second, Minute, Hour, Day, Week, Month, Quarter, Year. The alignment arguments are described here:&lt;/P&gt;
&lt;P class="HeadMinor"&gt;Start&amp;nbsp;is used to count the number of times an interval starts.&lt;/P&gt;
&lt;P class="HeadMinor"&gt;Actual&amp;nbsp;is used to count whole intervals.&lt;/P&gt;
&lt;P class="HeadMinor"&gt;Fractional&amp;nbsp;is used to count fractional intervals.&lt;/P&gt;
&lt;P class="HeadMinor"&gt;For example, the following formula returns &lt;SPAN class="command"&gt;207.890243055556&lt;/SPAN&gt;, the number of days between the dates:&lt;/P&gt;
&lt;P class="HeadMinor"&gt;&lt;SPAN class="code"&gt;Date Difference(01Jan2010:00:00:00, 27Jul2010:21:21:57, "Day", "fractional");&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="HeadMinor"&gt;The following formula returns &lt;SPAN class="command"&gt;207&lt;/SPAN&gt;, the number of completed days between the dates:&lt;/P&gt;
&lt;P class="HeadMinor"&gt;&lt;SPAN class="code"&gt;Date Difference(01Jan2010:00:00:00, 27Jul2010:21:21:57, "Day", "actual");&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="HeadMinor"&gt;The following formula returns 9, the number of completed hours between the times:&lt;/P&gt;
&lt;P class="HeadMinor"&gt;&lt;SPAN class="code"&gt;Date Difference(01Jan2010:00:00:00, 01Jan2010:09:22:57, "Hour", "actual");&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="HeadMinor"&gt;The following formula returns 1, the number of times a new hour started between the times:&lt;/P&gt;
&lt;P class="HeadMinor"&gt;&lt;SPAN class="code"&gt;Date Difference(31Dec2010:23:59:59, 01Jan2011:00:59:59, "Hour", "start");&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;alternatively you can run the following script and pay attention to the last comand with the formula of column 3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Table( "Untitled",
      Add Rows( 1 ),
      New Column( "Column 1",
            Numeric,
            Continuous,
            Format( "m/d/y", 12 ),
            Input Format( "m/d/y" ),
            Set Values( [2900620800] )
      ),
      New Column( "Column 2",
            Numeric,
            Continuous,
            Format( "m/d/y", 12 ),
            Input Format( "m/d/y" ),
            Set Values( [2900966400] )
      ),
      New Column( "Column 3",
            Numeric,
            Continuous,
            Format( "Best", Use thousands separator( 0 ), 17 ),
            Formula( Date Difference( :Column 1, :Column 2, "day", "actual" ) )
      )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;good luck!&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 09:15:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-you-calculate-number-of-days-between-two-dates/m-p/13981#M13120</guid>
      <dc:creator>ron_horne</dc:creator>
      <dc:date>2017-08-31T09:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: how do you calculate number of days between two dates?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-you-calculate-number-of-days-between-two-dates/m-p/13982#M13121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Goutam,&lt;/P&gt;&lt;P&gt;My pedestrian attempt gave a solution. Use column formula and subtract column 2 from columns 1 and then format columns 3 to display in days.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="9643_Screen Shot 2015-08-23 at 7.37.36 PM.png" style="width: 1920px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/2096iDCE5C17A09CCE5DC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="9643_Screen Shot 2015-08-23 at 7.37.36 PM.png" alt="9643_Screen Shot 2015-08-23 at 7.37.36 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2016 00:27:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-you-calculate-number-of-days-between-two-dates/m-p/13982#M13121</guid>
      <dc:creator>louv</dc:creator>
      <dc:date>2016-10-19T00:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: how do you calculate number of days between two dates?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-you-calculate-number-of-days-between-two-dates/m-p/13983#M13122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I find it much easier to do the math between dates in Excel and then transfer the results into a JMP table.&amp;nbsp; I know this sounds like blasphemy, but it is much easier and faster than trying to figure out the scripting needed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Aug 2015 11:31:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-you-calculate-number-of-days-between-two-dates/m-p/13983#M13122</guid>
      <dc:creator>Steven_Moore</dc:creator>
      <dc:date>2015-08-24T11:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: how do you calculate number of days between two dates?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-you-calculate-number-of-days-between-two-dates/m-p/13984#M13123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Smoore2,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would not go as far as saying that your statement is blasphemy, but in my experience, JMP is orders of magnitude better at handling date-times than Excel. Due to the nature of our work, we deal with timing data extensively. The very fact that JMP, unlike Excel, has a duration time format has been a godsend for us. I have lost count of the number of times that we have had to redo calculations in the past using Excel because of date-time format issues, but those problems disappeared once my analytical team began using JMP for analytics and became knowledgeable of how JMP handles date-times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have battled with date-time data in Excel for over a decade and often have to resort to VBA scripting to overcome Excel's shortcomings. Even then there was always the risk of someone getting a format issue. In JMP I have never needed to script date-time computations as most things can be handled by either using a simple formula and setting the format of a column or otherwise resolved with the extensive set of date-time functions JMP provides for column formulas. The screenshot below shows what the original poster wanted using three different methods already mentioned in this thread and required no scripting whatsoever.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="9657_Screenshot.png" style="width: 1554px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/2108i82EB7E9909D14647/image-size/medium?v=v2&amp;amp;px=400" role="button" title="9657_Screenshot.png" alt="9657_Screenshot.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The first difference uses a simple formula, (Date 2 - Date 1) / 86400, to compute the difference in days. Given that JMP stores date-times as a seconds count from 1 JAN 1904 12:00:00 AM, getting the number of days is just that simple. This method is useful for someone that wants any portion of days reported in decimal form.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second difference is even simpler as it does not require knowing the number of seconds in a day. The formula used is just Date 2 - Date 1, and the column is formatted as a duration (:day:hr:m). Using this method reports the number of days in time format show remaining time is shown as hours, minutes, and seconds.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The last method uses the Date Difference function and returns just the number of days. Admittedly, Excel does this by default if you subtract Date 1 from Date 2, but what JMP sacrifices by not just spitting out the number of days from Date 2 - Date 1 more than makes up for Excel's foibles with date-time computations. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2016 00:28:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-you-calculate-number-of-days-between-two-dates/m-p/13984#M13123</guid>
      <dc:creator>mdawson69</dc:creator>
      <dc:date>2016-10-19T00:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: how do you calculate number of days between two dates?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-you-calculate-number-of-days-between-two-dates/m-p/13985#M13124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Although JMP has its strengths, one place that Excel excels over JMP is in easy data conversion. (It's a trade-off: it seems that Excel is full of AI-like features where it tries to guess what you want, whereas JMP's behavior is more predictable.) Conversion of dates is a great example. When I started working with JMP, it took me a while to realize that the date formats that JMP recognizes weren't just examples, but an enumerated list of the ONLY ones it understood. Excel allows you to build custom date input formats using the h, m, s, d, y characters along with delimiters, and it converts text into the internal timestamp format.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Aug 2015 14:46:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-you-calculate-number-of-days-between-two-dates/m-p/13985#M13124</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-27T14:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: how do you calculate number of days between two dates?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-you-calculate-number-of-days-between-two-dates/m-p/233439#M46272</link>
      <description>Date Difference works perfectly.</description>
      <pubDate>Tue, 12 Nov 2019 23:30:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-you-calculate-number-of-days-between-two-dates/m-p/233439#M46272</guid>
      <dc:creator>Bass_Masri</dc:creator>
      <dc:date>2019-11-12T23:30:42Z</dc:date>
    </item>
  </channel>
</rss>

