I am trying to calculate the number of days since the start of the year in an automation, and am struggling to get it to calculate correctly.
I have tried various ways of doing it, and now have two variables:
YearStart: {{now.startOfMonth.withMonth(1)}}
NumberofDays: {{now.diff({{YearStart.toDate}}).days}}
When running it I get an error: Failed to get value for now().diff({{YearStart.toDate: {{now().diff({{YearStart.toDate}}).days}}
I am at a loss as to what to try next.
Hi, @Martin Hazell
Welcome to Atlassian Community
Try this formula. It works
{{YearStart.toDate.diff(now).days}}
I used variable YearStart like yours, but if you want, you can use such smart value, it will take 1 month, 1-st day, 1 minute.
{{now.startOfMonth.withMonth(1).withHour(0).withMinute(0)}}
Action details:
Log action
Log
YearStart: 2024-01-01T21:29:07.7+0000
Log action
Log
NumberofDays: 8
Fantastic - couldn't get my head round why at first.
This has worked.
Many thanks
Martin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I do not have Cloud instance to test it but this should work.
{{now.diff(now.startOfMonth.withMonth(1).withHour(0)).days}}
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.