Time Ranges with Templates

Time Ranges in SMS Reminders

If you are a service provider, perhaps Electrician, Plumber, General Repair or work in the Building Trades where you need to make house / service calls, you want to remind your clients of arrival times, but need to provide them a time window rather than a specific time.

If you use SMS Reminders, you can tell them when to expect you to show up.

For example:

Text message example

How do we create this time range? Let’s find out:

First, we want to figure out how we want to setup our time range. If you have 1-2pm on your Calendar for the service call, do you want to provide them a window of 11am to 1pm arrival time (2 hours prior to start time and start time), or say 1p to 3p arrival time (start time to 2 hours after start time). This will determine how you setup the formulas below.

For our examples we will create the range: start time to 2 hours after start time.

In our Template we will need to use some variables to setup the functionality.

First we setup 2 variables. The first one will be the “start time” of the event. We do this by using the advanced time to grab the “1” from the 1pm start time like so: (Note 1 is actually 13 since we want the 24 hour time format)

{% assign hour_time = event.date_time_advanced | date: "%H" %}

the 2nd variable we will ADD 2 hours to the “1pm” start time like so:

{% assign hour_time_short = hour_time | plus: 2 %}

Next we will want to use these variables in our text. But since %H above is a “24 hour” time (in other words, 1 = 13 we need to convert 13 or 15 to something in a 12 hour format), we need to do some IF THEN ELSE logic.

We will arrive between {{event.date_time_advanced | date: "%l%P" }} and {% if hour_time_short < 12 %}{{hour_time_short}}am{% elsif hour_time_short == 12 %}12pm{%else%}{{ hour_time_short | minus: 12 }}pm{%endif%}

What we did here is if the end time (the one where we add 2 hours to the start time) is less than 12pm we will show that time and append “am”, if its 12 we show “12pm” if it’s over 12 (meaning 13-24) we want to SUBTRACT 12 and append “pm” (so 15 – 12 = 3, thus 3pm)

Putting it all together:

{% assign hour_time = event.date_time_advanced | date: "%H" %}
{% assign hour_time_short = hour_time | plus: 2 %}
{{company.name}} is scheduled to arrive today between {{event.date_time_advanced | date: "%l:%M%P" }} and {% if hour_time_short < 12 %}{{hour_time_short}}:{{event.date_time_advanced | date: "%M" }}am{% elsif hour_time_short == 12 %}12pm{%else%}{{ hour_time_short | minus: 12 }}:{{event.date_time_advanced | date: "%M" }}pm{%endif%} at {{event.location}}.  Please reply YES to confirm or call {{user.phone}} to reschedule.

Note: GReminders uses the Liquid Templating Library. You can find all sorts of helpful functions and operators by reading their documentation.

Also note, by default SMS Reminder Templates are capped at 320 characters. If you need more characters to support more variables, please contact [email protected] and they will increase your template limit.

For more advanced topics like this please visit other articles:

Need help? Contact [email protected] and we would be happy to help you.

Happy Scheduling!

Want to Eliminate No Shows? Try GReminders today for Free

Try It Free Today!