Forums

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

Automation Assistance: Taking custom text field and using the date for the Start Date field

Kasper Ramstafer January 16, 2024

I have a custom text field called "Actual start date" that is written like this format (Tue, Jan 16, 2024) and I want to write an automation that takes the text date and adds it to the Start Date field.  I use the custom field ID number and I 've looked up that you have to change the format of the date field for it to show up in the Start Date field but everything I've tried the Start Date remains empty.  

I'll use this {{issue.fields.customfield_10306}} and I receive an error that the formatting doesn't match the Start Date field (which is "yyyy-MM-dd"). So then I tried: {{issue.fields.customfield_10306.format("yyyy-MM-dd")}} which doesn't receive an error but the start date field remains blank.  I read that a string can be converted to a date but is that possible? I've included a screenshot of the automation.jira question.png

 

1 answer

0 votes
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.
January 16, 2024

Hi @Kasper Ramstafer 

The format() function takes an object (like a date) and formats it as text: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/#Date-format---

Instead you want to take a text value and convert it to date type.  Please try using toDate for that.  As you have a non-standard format in that field, it would need the exact format specified.  For example:

{{issue.customfield_10306.toDate("EEE, MMM dd, yyyy")}}

Please review the format() function's additional details to confirm the format matches what you need.

Kind regards,
Bill

Kasper Ramstafer January 19, 2024

Thank you for your help on this! For some reason using the code without the EEE part works but not with the EEE.  The output is 2025-02-05T00:00:00.0+0000.  Do you know how I can make that at least just look like this "Feb 05, 2025"?  Would I need to create a variable and save the {{issue.customfield_10306.toDate("MMM dd, yyyy")}} to it then use the format function with the mediumDate format to make it fit the correct format as the Start Date field?

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.
January 20, 2024

To format a date in a particular text layout, please use the format() function, or one of the built-in formats.

To change the displayed format for a date field on an issue view, please check your profile settings and /or the site settings.

Kasper Ramstafer January 22, 2024

Thank you for your help!

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer