Insert Date in Macro | The place for Zendesk users to come together and share
Skip to main content
September 20, 2016
Question

Insert Date in Macro

  • September 20, 2016
  • 24 replies
  • 77 views

We have a Macro with a comment and we would like to include today's date in the Macro. Is there a placeholder for today's date that we can use?

For example, the Comment reads:

We have referred this to our tech support team on {today's date} and they typically respond to clients in 1-2 hours.

This topic has been closed for replies.

24 replies

June 5, 2020

Is it possible to generate a date for "Next Sunday"

We deploy patches on Sunday and I would like to have a macro that inserted this day.  

So if I ran it today (June 5) it would inset June 7

June 5, 2020

@Jeff Callahan

there may be a simpler way to do it but this should work

finds day of week, minuses day of the week from 7. takes that calculates the seconds and then adds that to the current date.

test it out

{% assign today = 'now' | date: '%u' %}{% assign dayWeek = 7 | minus: today %}
{% assign seconds = dayWeek | times: 24 | times: 60 | times: 60 %}
{{ 'now' | date: '%s' | plus: seconds | date: '%Y-%m-%d' }}

July 16, 2020

Is there a code to generate a date 3 days from today not taking into consideration weekends? Thanks

July 16, 2020

@Mauricio Rincon C

You want it to count three days in the future but not the weekends? If so, try out the below

Assigns today -> the day of the week

If wed -> then add 5 days in seconds to now == mon

if thurs -> then add 4 days in seconds to now == mon

else -> add 3 days in seconds to now

{% assign today = 'now' | date: '%A' %}
{% if  today == 'Wednesday' %}
{{ 'now' | date: '%s' | plus:432000 | date: '%Y-%m-%d' }}
{% elsif today == 'Thursday' %}
{{ 'now' | date: '%s' | plus:345600 | date: '%Y-%m-%d' }}

{% else %}
{{ 'now' | date: '%s' | plus:259200 | date: '%Y-%m-%d' }}
{% endif %}