i have email template for our lead follow up emails where we usually suggest a date 2 business days of sending the email. currently, it is a pain to manually update the date every time we send email. is there a way to insert it dynamically the way we can do the personalization attributes?
I'm building a workflow that creates a daily task. To differentiate between days, I want it to be Task Title [Today's Date]. Therefore I just need the code for today's date. Can you please share?
Since this thread still gets activity just wanted to note that datetimeformat() has been deprecated and replaced with format_datetime, format_date, and format_time. I just released a blog post that talks about dynamic dates in detail with many exmaples of these new functions if you want to learn more : https://www.alyssawilie.com/blog/add-dynamic-dates-to-automated-emails
If this answer solved your question, please mark it as the solution.
Hi, I'm using this to insert a dynamic date into an email and it works great! I was wondering if it's possible to have the date appear inline with preceeding text? I'd like to have a line that reads, "Sale ends ________" but currently it will put the dynamically generated date onto the next line which looks odd.
Thanks for the quick response. Would you mind showing me an example? I did try that but I must have done something wrong because it didn’t work. Thank you!
Sorry, this is my first time trying something like this and I'm still doing something wrong. This is what I'm currently using but it splits it over 2 lines.
Sale Ends {% set future_date = local_dt|plus_time(10, 'days')%} {{ datetimeformat(future_date, '%B %e, %Y') }} at Midnight
Would like it all to appear on one line. Thanks again for being so helpful
Sep 9, 202111:29 AM - edited Sep 10, 20211:18 PM
Top Contributor
inserting date into email template
SOLVE
@alyssamwilie This is really great, thanks for the solution. I'm curious to how this would work if I only wanted to show the next 4 business days? If its showing today (a Thursday), it would show Friday, Monday, and Tuesday. Is that possible through Hubl?
@spogue Not sure if you can get them concurrently but you can use multiple plus_time calls to get the next three days and %A in the format to get the weekday.
@alyssamwilie Makes sense. Have you ever seen code to only show business days?
For example, if I took the way you just wrote the code, but I only wanted to show the next 3 business days, is there a way to "skip" weekdays if one of those days is a Saturday or Sunday? Like this:
@spogue You can use a for loop and if statements to increase the plus_time if the weekday lands on a Saturday or Sunday. You'll probably want to put this in a custom module instead of directly in the email though.