The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Calculate number of days between a date field and the end of the year

Francesco Borgosano
January 13, 2023

Hi,

 

I am trying to use Automation and Smart Values to automatically calculate the number of days between a date and the end of the year of the same date.

For example, if the date field value is 23/Jun/2024. I would like to know how many days are between that and 31/Dec/2024.

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

4 votes
Answer accepted
Trudy P Claspill
Community Champion
January 13, 2023

Hello @Francesco Borgosano 

What have you tried?

You can get the difference between two dates using the diff function.

{{[date1].diff([date2]).[unit]}}

Reference this document:

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time

If you need to construct the year-end date based on the Year specified in the date field use the format function on the date field to get the year. Example:

{{issue.created.format("yyyy")}}

Substitute your date field for "created".

Combine this with the day and month to get the year-end date, and use that to set a variable.

Screen Shot 2023-01-13 at 2.48.50 PM.png

 

That variable is a string so when you use it in the date diff function you need to convert it to a date.

{{now().diff(yearEnd.toDate).Days}}

 

Francesco Borgosano
January 24, 2023

Hi @Trudy P Claspill,

 

thanks for your reply. Your solution worked!

 

And I found particularly insightful and elegant your solution with the concept of creating a local variable. It gave me other ideas for further automation.  

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events