Forums

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

Asset Date Format

Patricia Molina March 26, 2025

Hi Everyone, I am on Jira Data Center 9.12.17 with JSM.

I have assets that have a License End Date attribute. I have setup automation to send emails when they are about to expire. What is sent in the email is the following:

Name: Knowbe4
Description: `Knowbe4 Security Awareness training
License Start Date: 1712016000000
License End Date: 1743566400000

The dates are in the wrong format even though they show correctly in Assets:

asset.JPG

 

Here what my automation looks like:

automation.JPG

I have tried different smart values formatting like {{attributes.License End Date2.jiraDate}} or

 

 {{attributes.License End Date2.format("mm/dd/yyyy")}} and nothing seems to work.

Any help is appreciated!

4 answers

1 accepted

0 votes
Answer accepted
Patricia Molina May 9, 2025

This is what worked for me after consulting with Atlassian support:

I had to create a personal authentication token and then use that in the automation rule:

Rule1.JPGRule2.JPG

Let me know if you need more info.

1 vote
Emmanuel Abwao March 26, 2025

Hello Patricia,

The issue here is that the License Start Date and License End Date values are being displayed as Unix timestamps. The reason {{attributes.License End Date2.format("mm/dd/yyyy")}} did not work correctly is due to Incorrect Format Specifier for Month. mm Represents minutes, not months.

Try this solution:
License Start Date: {{attributes.License Start Date.format("EEEE, MMMM dd, yyyy")}}
License End Date: {{attributes.License End Date2.format("EEEE, MMMM dd, yyyy")}}

Expected Output:
License Start Date: Tuesday, April 02, 2024
License End Date: Thursday, May 02, 2025

If you want the date format as 07/06/2025 (MM/dd/yyyy), use:
{{attributes.License End Date.format("MM/dd/yyyy")}}

Let me how it goes.

Patricia Molina March 31, 2025

Thank you for the response @Emmanuel Abwao. Unfortunately that did not work. Here is what I am seeing in the email:

The following software license is due to expire soon:

Name: Knowbe4
Description: `Knowbe4 Security Awareness training
License Start Date: 1712016000000
License End Date: MM/dd/yyyy1743552000000

Emmanuel Abwao March 31, 2025

Hello Patricia. If it is possible, you may attach the image of the attribute and the smart values you've inserted. The syntax might be a problem. Let me know as soon as you do.

Patricia Molina April 1, 2025

Hi @Emmanuel Abwao 

Here is my code:

I have tried this:
{{#lookupAssets}}
Name: {{attributes.Name}}
Description: {{attributes.Description}}
License Start Date: {{attributes.License Start Date}}
License End Date: {{attributes.License End Date.toDate("MM/dd/yyyy")}}
{{/}}

And here is the other one you told me to try:

{{#lookupAssets}}
Name: {{attributes.Name}}
Description: {{attributes.Description}}
License Start Date: {{attributes.License Start Date}}
License End Date: {{attributes.License End Date.format("MM/dd/yyyy")}}
{{/}}

Trudy Claspill
Community Champion
May 8, 2025

@Patricia Molina @Emmanuel Abwao 

Did you figure this out? I'm encountering the same issue.

Trudy Claspill
Community Champion
May 8, 2025

The answer has been marked as accepted. What is the solution that actually works? The suggestion to use the format command doesn't work.

Patricia Molina May 9, 2025

Hi @Trudy Claspill I unmarked the answer as unaccepted. I had to talk to Atlassian support in order to get it to work correctly. We ended up using /rest api in order to get the data and then convert it from there. If you need those steps let me know and I can add them here.

Trudy Claspill
Community Champion
May 9, 2025

Hello @Patricia Molina 

Please do add them. If you add them using the "Suggest an answer" entry at the bottom of the replies then you can mark your own answer as Accepted.

0 votes
Darryl Lee
Community Champion
May 8, 2025

Oh man, yeah, so as @Emmanuel Abwao pointed out, Assets stores dates as Unix timestamps (also known as epoch time) and despite the optimism of @Shawn Doyle - ReleaseTEAM back in July that Atlassian would eventually get around to "Atlassianize"-ing Assets codebase to behave like other date fields, that doesn't seem to have happened yet.

Anyways, Unix time is defined by Wikipedia thusly:

It measures time by the number of non-leap seconds that have elapsed since 00:00:00 UTC on 1 January 1970, the Unix epoch. For example, at midnight on 1 January 2010, Unix time was 1262304000.

SO ANYWAYS, way back in 2021, @Italo _Modus Create_ came up with the solution here that I'm adapting:

  1. Create variable epochDate: 01/01/1970
  2. Create dateStamp variable:
    {{epochDate.toDate("dd/MM/yyyy").plusMillis(lookupAsset.attributes."Site Bio Review - Date of Assessment".asNumber).format("MM/dd/yyyy")}}
  3. ?
  4. Profit!

So yeah, Italo's brilliant solution was to convert the Epoch (01/01/1970) to a date object using the toDate function, and THEN use plusMillis to add your asset's timestamp (which is millliseconds since Epoch, not seconds). Finally we use format to get MM/dd/yyyy that you want.

Trudy Claspill
Community Champion
May 9, 2025

I found a similar solution from @Bill Sheboy here.

The asNumber function is not support in Automation on Jira Data Center.

While {{lookupAsset.attributes."Name of Date attribute"}} yields a value like

1743984000000

{{lookupAsset.attributes."Name of Date attribute".asNumber}} yields no data.

 

I also looked at stuffing the value into a Number field (Story Points) in the issue, but in my case that cannot be done because it caused an error in the database trying to convert a Float to a Numeric.

Screenshot 2025-05-08 at 11.42.17 PM.png

But I found that I could store this number: 1743984000 (the original number divided by 1000 to get Seconds)

I could then use it thus:

{{now.toStartOfDay.withYear(1970).withDayOfYear(1).plusSeconds(issue."Number field")}}

Unfortunately I have not yet figured out how to convert the asset date to a number that can be added to the field.

{{#=}} {{lookupAsset.attributes."Name of Date Attribute"}} / 1000 {{/}}

...yielded the right number - 1743984000.

But when I tried to use the math function to set the Number Field in the issue, the field did not get set and no error was reported.

I also tried creating a variable set to the above math function and then setting the issue Number Field to the variable, but that circles back to not being able to use a string when a number is expected.

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 9, 2025

Hi @Trudy Claspill 

A couple of things to try...

#1) Where you copied the number and got the float conversion error, try adding floor to force the value to an integer first.

 

#2) Try using the longer format of date math expressions, which works for Cloud but I do not know if it works for Server / Data Center.  The idea is to first create a variable for the start-of-epoch-time, and then add your number of seconds, wrapped in a math expression.

For example:

  • action: create variable
    • name: varStartOfTime
    • value: {{now.withYear(1970).withDayOfYear(1).toDateTimeAtStartOfDay}}
  • action: create variable
    • name: varSecondsToAdd
    • value: your expression to get the seconds
  • action: create variable
    • name: varDateValue
    • value: {{#varStartOfTime.toDate}}func=plusSeconds({{#=}}{{varSecondsToAdd}}{{/}}){{/}}
  • use the date as {{varDateValue.toDate}}

 

For some reason, this cannot all be done in one step with Cloud, but please experiment to learn if it works and can be condensed for Server / Data Center.

 

Kind regards,
Bill

Like Matt Doar _Adaptavist_ likes this
Trudy Claspill
Community Champion
May 9, 2025

Thank you for the feedback @Bill Sheboy 

#1) Where you copied the number and got the float conversion error, try adding floor to force the value to an integer first.

That was in the Edit Issue screen in the UI.

#2

I tried this originally from your solution:

{{now.withYear(1970).withDayOfYear(1).toDateTimeAtStartOfDay}}

It yielded no value. The components worked until I added .toDateTimeAtStartOfDay

Subsequently I found that this worked instead:

{{now.toStartOfDay.withYear(1970).withDayOfYear(1)}}

 

Otherwise I tested your solution and it appears to work!! I'm going to do more testing to make sure.

Screenshot 2025-05-09 at 8.47.34 AM.png

Like # people like this
0 votes
Rodney Estrada
Contributor
March 28, 2025

Great answer @Emmanuel Abwao . Do you happen to have a link for that?

I'd like to learn what else I can customize. Thank you,

Emmanuel Abwao March 28, 2025

Thanks Rodney,
For the customization of dates, use the java date pattern syntax. Here is an example:
Data and Time Format

To use them in relation to Atlassian's smart values like in assets above, you may want to read this:
Automation smart values - date and time | Cloud automation Cloud | Atlassian Support

I hope that helps.

Like Rodney Estrada likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events