Recent searches


No recent searches

Date Placeholders

Answered


Posted Dec 11, 2023

Is there a way to create a date placeholder for next business day using Monday-Friday as main operation days?


4

7

7 comments

image avatar

Brandon Taylor

Zendesk Luminary

Hi Jill,

To create a date placeholder for the next business day in Zendesk, you can use the Liquid markup language to add one day to the current date and check if it is a weekday. For example, you can use the following syntax to display the next business day in YYYY-MM-DD format:

{% capture tomorrow %} {{'now' | date:'%Y-%m-%d' | plus: 86400}} {% endcapture %} {% if tomorrow | date: '%a' == 'Sat' %} {% capture next_business_day %} {{tomorrow | plus: 172800}} {% endcapture %} {% elsif tomorrow | date: '%a' == 'Sun' %} {% capture next_business_day %} {{tomorrow | plus: 86400}} {% endcapture %} {% else %} {% capture next_business_day %} {{tomorrow}} {% endcapture %} {% endif %} {{next_business_day}}

This will output something like this:

2023-12-15

For more information on how to use date placeholders in Zendesk, you can check out these resources:

I hope this helps. If you have any other questions, feel free to ask me. 😊

1


Thanks Brandon Taylor When using this I don't seem to be receiving 2023-12-15 but getting 261223 any suggestions? 

1


image avatar

Brandon Taylor

Zendesk Luminary

Sorry Jill, I should have tested first to confirm what my brain said was right :) 

Here's the revised markup that I've tested and outputs correctly:


{% assign current_day_of_week = 'now' | date: "%w" %} {% assign days_to_add = 1 %} {% if current_day_of_week == '5' %} {% assign days_to_add = 3 %} {% elsif current_day_of_week == '6' %} {% assign days_to_add = 2 %} {% endif %} {% assign seconds_in_a_day = 86400 %} {% assign additional_seconds = days_to_add | times: seconds_in_a_day %} {% assign next_business_day = 'now' | date: "%s" | plus: additional_seconds %} Next Business Day: {{ next_business_day | date: "%Y-%m-%d" }}

3


Brandon Taylor You're the best, it works! :-) 

0


image avatar

Brett Bowser

Zendesk Community Manager

Awesome solution Brandon Taylor! Thanks for taking the time to share this with Jill :) 

0


Why is this question downvoted? Most people would struggle to find a solution to this, including me (a programmer) since I am not too familiar with liquid markup. Thank you Jill for the question and Brandon for the solution! I was able to adjust the solution to my needs.

0


image avatar

Brandon Taylor

Zendesk Luminary

My pleasure Jack Cho ! I'm not sure why this was downvoted so much either 🤔 Brett Bowser any idea why folks dislike this post?

1


Please sign in to leave a comment.

Didn't find what you're looking for?

New post