Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
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
Highlighted

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! 

Learn it once, use it forever!

View solution in original post

4 REPLIES 4
Highlighted

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! 

Learn it once, use it forever!

View solution in original post

Highlighted
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.

Highlighted
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
Highlighted

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.

Learn it once, use it forever!
Article Labels

    There are no labels assigned to this post.