cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
lizrdee
Level II

Breaking down time of day into shifts

Hello, 

 

I have time data that I would like to breakdown into shifts to analyze shift patterns 
9:00PM-5:59AM = night shift

6:00AM-11:59AM = morning shift

12:00PM-8:59PM = afternoon shift

 

 

Can anyone provide any guidance on how to do this with a formula or script? I'm a beginner and am just using recode which is very slow. 

Time column.JPG

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Breaking down time of day into shifts

You can copy this script and then paste it as the formula for the second column:

 

If(
	In Hours( 6 ) <= :CST < In Hours( 12 ), "Morning Shift",
	In Hours( 12 ) <= :CST < In Hours( 21 ), "Afternoon Shift",
	"Night Shift",
);

I can't test it but you can! 

View solution in original post

4 REPLIES 4

Re: Breaking down time of day into shifts

You can copy this script and then paste it as the formula for the second column:

 

If(
	In Hours( 6 ) <= :CST < In Hours( 12 ), "Morning Shift",
	In Hours( 12 ) <= :CST < In Hours( 21 ), "Afternoon Shift",
	"Night Shift",
);

I can't test it but you can! 

lizrdee
Level II

Re: Breaking down time of day into shifts

Thank you so much it worked! I was wondering how to format the formula so this was really helpful.

Jeff_Perkinson
Community Manager Community Manager

Re: Breaking down time of day into shifts

You might find value in Using dates, times, datetimes and durations in JMP

-Jeff

Re: Breaking down time of day into shifts

I amended my solution to use literal times instead of computing them.

 

If(
	06:00:00 <= :CST < 12:00:00, "Morning Shift",
	12:00:00 <= :CST < 21:00:00, "Afternoon Shift",
	"Night Shift",
);

I think that it improves the legibility and efficiency of this formula.

Recommended Articles