Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Get the Hour of field created - Using scritprunner

Hi!

 

I need some help here. I'm trying to create a scripted field to show which work shift it was created. 

To do that, I need to get the hour of the field "Created"

Could anybody help me to develop the code?

 

I checked this post and saw how to get the full created date. But all I need is the hour.

https://community.atlassian.com/t5/Jira-questions/Script-Runner-how-do-I-pull-Created-Date-information-from-an/qaq-p/4832

 

If an issue is created at 05:22AM, it should be "Shift1";

If an issue is created at 10:01AM, it is "Administrative Shift"

 

1 answer

Hi Yuri,

Thank you for your question.

I can confirm that the best way to achieve your requirement would be to get the value from the created field as you have done and to save this value into a date variable inside of your script.

I can confirm that you would then be able to write some logic inside of your code to extract the hour from the date variable and the example located here shows an example of how to extract the hour from the current date.

Also I can confirm we have a code sample located here which can be run on the Script Console and shows how to get the hour an issue was created from the created field.

Once you have got the hour that the issue was created in your script then you could write some  if statements to check if the hour matches a specific hour and if it does add the code to set the field value to the value you require inside the If block.

These examples will be a good reference guide to help show you can extract the current hour out of the created date and to help create the script that you require.

I hope this information helps.

Regards,

Kristian

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Happy New Year and Welcome New Marketplace Partner Program Partners!

Happy New Year! We hope you all had a safe and restful holiday season. 2020 was a unique year full of unforeseen events; however, as we enter the new year of 2021, we’re optimistic for the light at t...

452 views 6 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you