Performance Analytics Scripts - Get Hour from DateTime field

Michael Johnsto
Mega Contributor

I am trying to use a script in Performance Analytics to determine if a change request was done during business hours. (started after 9am). It seems like I should be able to get the hour from the Actual Start field, but I am getting a NaN error on the data collection for some of the records passed to the script.   Can anyone give some suggestions on why simple code like this doesn't work?    Thanks. 

 

var hour = current.work_start.getHours();

var nhour = parseInt(hour.getByFormat('HH);

 

nhour should now have the hour of the Actual start time in number format?   

1 ACCEPTED SOLUTION

AndersBGS
Tera Patron
Tera Patron

Hi @Michael Johnsto ,

 

Why do you want to script when you instead just can utilize the condition builder:

AndersBGS_0-1709304177048.png

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

best regards

Anders

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

View solution in original post

2 REPLIES 2

AndersBGS
Tera Patron
Tera Patron

Hi @Michael Johnsto ,

 

Why do you want to script when you instead just can utilize the condition builder:

AndersBGS_0-1709304177048.png

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

best regards

Anders

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

Thanks, that is a good suggestion which should work in this case.