<?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: How do I create a formula column with custom dates/shift? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-create-a-formula-column-with-custom-dates-shift/m-p/340068#M58845</link>
    <description>&lt;P&gt;I think the best way to handle this, is to do a correction on the date time values by subtracting off 7 hours, which makes the shifts line up with the day values&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;correctedDate = :date - In Hours( 7 );
"WW" || Char( Week Of Year( correctedDate ) ) || "." || Char( Day Of Week( correctedDate ) - 1 ) ||
If( Hour( correctedDate ) &amp;gt;= 0 &amp;amp; Hour( correctedDate ) &amp;lt;= 12,
	"D",
	"N"
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 08 Dec 2020 07:22:13 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2020-12-08T07:22:13Z</dc:date>
    <item>
      <title>How do I create a formula column with custom dates/shift?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-create-a-formula-column-with-custom-dates-shift/m-p/340029#M58843</link>
      <description>&lt;P&gt;I'm working on an analysis related to working shift strucutre. We operate 12 hours per shift. Meaning we work from 7am-7pm (Day shift, D) and 7pm - 7am (Night shift, N).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently I have a formula column script as follows:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;"WW" || Char (Week of Year (:date)) || "." || Char (Day of week (:date) - 1) || 
If (Hour (:date) &amp;lt;= 19 &amp;amp; Hour(:date) &amp;gt;= 7, "D", "N")&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Seems like it doesnt work the way I expected bcs based on this script, it changed to new day whenever the time reached 12am.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;The script will convert 12/01/2020 5:49:47 AM to WW49.2N. It should be WW49.1N. WW49.2D starts when the date and time is 12/01/2020 7:00:00 AM This is because the time for night shift is from 7pm-7am. Can someone suggest or advise an alternative way to create the script?&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:23:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-create-a-formula-column-with-custom-dates-shift/m-p/340029#M58843</guid>
      <dc:creator>Danial1</dc:creator>
      <dc:date>2023-06-10T23:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a formula column with custom dates/shift?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-create-a-formula-column-with-custom-dates-shift/m-p/340068#M58845</link>
      <description>&lt;P&gt;I think the best way to handle this, is to do a correction on the date time values by subtracting off 7 hours, which makes the shifts line up with the day values&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;correctedDate = :date - In Hours( 7 );
"WW" || Char( Week Of Year( correctedDate ) ) || "." || Char( Day Of Week( correctedDate ) - 1 ) ||
If( Hour( correctedDate ) &amp;gt;= 0 &amp;amp; Hour( correctedDate ) &amp;lt;= 12,
	"D",
	"N"
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Dec 2020 07:22:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-create-a-formula-column-with-custom-dates-shift/m-p/340068#M58845</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-12-08T07:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a formula column with custom dates/shift?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-create-a-formula-column-with-custom-dates-shift/m-p/340181#M58858</link>
      <description>&lt;P&gt;just wanted to confirm, when you say -&amp;nbsp;&lt;CODE class=" language-jsl"&gt;In Hours( 7 )&lt;/CODE&gt;&amp;nbsp;does it mean substrate 7 hours?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2020 15:15:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-create-a-formula-column-with-custom-dates-shift/m-p/340181#M58858</guid>
      <dc:creator>Danial1</dc:creator>
      <dc:date>2020-12-08T15:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a formula column with custom dates/shift?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-create-a-formula-column-with-custom-dates-shift/m-p/340184#M58859</link>
      <description>&lt;P&gt;It subtracts 25200 seconds from the specified value for the column Date for the current row. &lt;BR /&gt;25200 = 60 seconds per minute X 60 minutes per hour X 7 hours&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, I made a slight error in my formula.&amp;nbsp; The If() comparison should have a "&amp;lt;" comparison for the second element, not "&amp;lt;="&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;correctedDate = :date - In Hours( 7 );
"WW" || Char( Week Of Year( correctedDate ) ) || "." || Char( Day Of Week( correctedDate ) - 1 ) ||
If( Hour( correctedDate ) &amp;gt;= 0 &amp;amp; Hour( correctedDate ) &amp;lt; 12,
	"D",
	"N"
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Dec 2020 15:33:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-create-a-formula-column-with-custom-dates-shift/m-p/340184#M58859</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-12-08T15:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a formula column with custom dates/shift?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-create-a-formula-column-with-custom-dates-shift/m-p/340384#M58881</link>
      <description>&lt;P&gt;I see so jmp would always compute in seconds. btw&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;could you explain why we need to substract 7 hours (25,200 seconds) from the actual time?&lt;/P&gt;&lt;P&gt;The scripted condition says any time between 12am - 12pm is Day ("D")&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2020 00:18:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-create-a-formula-column-with-custom-dates-shift/m-p/340384#M58881</guid>
      <dc:creator>Danial1</dc:creator>
      <dc:date>2020-12-09T00:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a formula column with custom dates/shift?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-create-a-formula-column-with-custom-dates-shift/m-p/340385#M58882</link>
      <description>&lt;P&gt;Your shifts are from 7am-7pm D, and 7pm-7am N.&amp;nbsp; &amp;nbsp;If a time for the 2nd day night shift is beyond 12 midnight, JMP will return the Day(:date) will return day 3, since JMP measures days based upon midnight.&amp;nbsp; However, if for the calculations, we shift the :date value back by 7 hours, that will mean that the night shift will be from noon to midnight, and never crossing the JMP day boundry.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2020 01:55:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-create-a-formula-column-with-custom-dates-shift/m-p/340385#M58882</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-12-09T01:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a formula column with custom dates/shift?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-create-a-formula-column-with-custom-dates-shift/m-p/882389#M104631</link>
      <description>&lt;P&gt;This is interesting, since you could have swapped the positions of the &amp;gt;= and &amp;lt; in the formula:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;correctedDate = :date - In Hours( 7 );
"WW" || Char( Week Of Year( correctedDate ) ) || "." || Char( Day Of Week( correctedDate ) - 1 ) ||
If( 0 &amp;lt; Hour( correctedDate ) &amp;lt;= 12,
	"D",
	"N"
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am working on a similar problem and the assignment of night vs day shift is slightly different, depending on which relative positions the &amp;lt; and &amp;lt;= symbols have in the if statement. It would be great to allow for direct use of timestamps inside the if formula (if time &amp;gt; 12:00:00 ...). Maybe it is, I haven't researched enough.&lt;/P&gt;
&lt;P&gt;However, my main question: &lt;STRONG&gt;How did you decide where to put the &amp;lt; and &amp;lt;= symbols?&lt;/STRONG&gt; Naturally, it is important to have an equal division of 12 hours per shift, but this could be achieved with both configurations (&amp;lt; before &amp;lt;=, and &amp;lt;= before &amp;lt;).&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jun 2025 12:58:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-create-a-formula-column-with-custom-dates-shift/m-p/882389#M104631</guid>
      <dc:creator>Ressel</dc:creator>
      <dc:date>2025-06-30T12:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a formula column with custom dates/shift?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-create-a-formula-column-with-custom-dates-shift/m-p/882401#M104633</link>
      <description>&lt;P&gt;7PM is the start of the new shift which is hour() 19.&amp;nbsp; Since we are taking a 7 hour offset, the Hour() value that starts the night shift is 19-7 which is 12.&amp;nbsp; If the comparison was &amp;lt;= then a time value of exactly 12 would be considered a day shift.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jun 2025 13:52:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-create-a-formula-column-with-custom-dates-shift/m-p/882401#M104633</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2025-06-30T13:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a formula column with custom dates/shift?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-create-a-formula-column-with-custom-dates-shift/m-p/882403#M104634</link>
      <description>&lt;P&gt;Thanks, I realized this later when tinkering with own file - naturally, after I had posted my not-so-well-thought-through question. Thank you for your patience.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jun 2025 14:46:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-create-a-formula-column-with-custom-dates-shift/m-p/882403#M104634</guid>
      <dc:creator>Ressel</dc:creator>
      <dc:date>2025-06-30T14:46:15Z</dc:date>
    </item>
  </channel>
</rss>

