Solved

2 week duration

  • 16 May 2023
  • 4 replies
  • 121 views

Badge +1

I want to add a 2 week duration to a ticket.  I use the following formula in the expression builder and I am not able to get the formula to add 14 days or save as a string value

"{{ticket.created_at | date: '%Y-%m-%d'}} - {{ticket.created_at | date: '%Y-%m-%d' | date_add: '+14 days'}}"

What am I missing?

icon

Best answer by bradberryromero 14 July 2023, 12:33

View original

4 replies

It seems like you're using the correct syntax for adding 14 days to the created_at date and formatting it as a string in the format YYYY-MM-DD. However, the resulting expression is a string that concatenates the original created_at date and the new date 14 days later, separated by a dash.

If you want to use the resulting date in your ticket, you might need to use the expression in a different way. For example, you could use it to set a custom ticket field with the new date value:

  1. Go to your Zendesk Support account and select the "Admin" icon.
  2. Under "Manage" select "Ticket fields".
  3. Click the "Add field" button and create a new field with a name like "New Date".
  4. Under "Field Type" select "Date".
  5. Save the new field and go to your ticket form settings to add it to your form.
  6. In your expression builder, use the following formula to set the new field with the date 14 days after the created_at date:
 

bashCopy code

{{ticket.created_at | date_add: '+14d' | date: '%Y-%m-%d'}}

  1. Save the ticket, and the "New Date" field should now show the date 14 days after the created_at date.

Note that if you want to use the resulting date in a different way, such as adding it to the ticket comment or as a tag, you might need to modify the expression accordingly.

Badge

The formula you provided looks correct for adding 14 days to the ticket's creation date. However, it seems that you are using the Liquid date filter syntax, which might not be compatible with the expression builder in your specific context.

Instead, you can try using the built-in date functions provided by the platform you are using. Here's an example of how you can add a 2-week duration to a ticket using the expression builder:

1. Determine the ticket's creation date format. For example, if the creation date format is "YYYY-MM-DD", make sure to adjust the format in the following steps accordingly.

2. Use the appropriate date functions provided by the expression builder to add 14 days to the creation date. The exact syntax may vary depending on the platform, but here's an example:

   `DATE_ADD({{ticket.created_at}}, INTERVAL 14 DAY)`

   This expression will add 14 days to the ticket's creation date.

3. Format the resulting date value if necessary. You can apply the desired date format using the appropriate function or syntax provided by the platform.

Make sure to consult the documentation or resources specific to the platform you are using to ensure the correct usage of date functions and syntax within the expression builder.

 

Regards; 

David Johnson.

It appears that you're attempting to add a 2-week duration to a ticket using an expression in the expression builder. The formula you provided seems correct, but you mentioned encountering difficulties in getting the formula to add 14 days or save as a string value.

To troubleshoot the issue, consider the following steps:

  1. Verify the date format: Make sure that the 'ticket.created_at' value is in the correct format expected by the expression builder, which should be '%Y-%m-%d'. Double-check the format of the 'created_at' value to ensure it matches the required format.

  2. Confirm the date_add function: Check if the 'date_add' function is supported and properly implemented in the expression builder you are using. Different systems or platforms might have variations in syntax or supported date manipulation functions.

  3. Check for any limitations: Review the documentation or guidelines of the expression builder or platform you are working with to see if there are any limitations or specific requirements for manipulating dates.

If you have examined these aspects and are still encountering issues, it might be beneficial to consult the documentation or seek support resources specific to the expression builder or platform you are using. They can provide valuable insights into any additional steps or considerations necessary to successfully add a 2-week duration to the ticket or save it as a string value, catering to the unique requirements of your setup.

The solution you provided seems accurate for increasing the ticket's creation date by 14 days. Nevertheless, it appears that you're employing the Liquid date filter syntax, which might not be suitable for the expression builder in your particular context.

Instead, I recommend utilizing the built-in date manipulation functions offered by the platform you're working on. Here's an illustrative instance of how you can incorporate a two-week duration into a ticket using the expression builder:

  1. Identify the precise format of the ticket's creation date. For instance, if the format is "YYYY-MM-DD," make sure to adjust subsequent steps to match this format.

  2. Employ the appropriate date manipulation functions available in the expression builder to append 14 days to the creation date. The exact syntax could differ based on the platform, but consider this example:

    DATE_ADD({{ticket.created_at}}, INTERVAL 14 DAY)

    This expression effectively adds 14 days to the ticket's creation date.

  3. Modify the resultant date value if needed. You can implement the desired date format using the relevant functions or syntax provided by your platform.

For accurate usage of date functions and syntax within the expression builder, I suggest referring to the platform-specific documentation or resources. This will ensure precise implementation in your context.

Reply