Xmerge coding query
Might be one for you courtney.youngblutt.
Can you adapt this code to display the previous month?
<:=datetime_merge.format(‘%Y %B’):> (2025 April)
Can we make it display 2025 March? I want to use this in an email template and email subject line.
Thank you as always. I will give this a crack, and it should work for my purpose as I will be sending automated monthly reports from IPS to our clients approximately mid month.
2 Replies
- courtney.youngblutt
Iress Contributor
Thanks luke.watson3 - I am definitely not a champion coder and had to use a lifeline for this one. 😄
The tricky bit with this is that email syntax differs from xmerge syntax used in word templates. So while <:= dateutils.dateToStr(dateutils.getEndOfLastMonth(int(today)), format='%Y %B'):> works in a word document, it doesn't work in an email template.
For email try:
<:=datetime_merge.fromordinal(datetime_merge.toordinal() - 30).strftime('%Y %B'):>
⚠️ There is a limitation though - this code will merge the month based on the date that was 30 days ago (-30). So if the email is sent on the 15th of the month, you will likely get the result you are after, but if sent on the 31st day of a month, it won't work as expected.
Let me know if the code I provided doesn't do what you need it to and we can brainstorm some alternatives.
Otherwise, I'd love to hear from any expert coders out there who may have an alternative solution for email syntax that might work in this instance.
And while the answer to your specific question Luke, was not in our Community resources, for others who might be reading this - there is a reasonably comprehensive library of codes in the Xmerge Library in Community that can be useful when trying to source codes for your templates. I've also found the blog articles on the following website to be super useful in helping me understand how xmerge code functions - https://www.createsomething.com.au/blog/
And, while again it didn't help me in this particular instance - Chat GPT or similar has also helped me work out codes in the past!
- luke.watson3
Advisely Contributor
Thank you as always. I will give this a crack, and it should work for my purpose as I will be sending automated monthly reports from IPS to our clients approximately mid month.
Recent Discussions
Xplan Case Benchmarks - Outcome of task
Hi, we have set up our case benchmarks but not all of them can be automated or we have chosen not to automate some and require the adviser/paraplanner/admin/compliance staff member to go and link cer...edward.wilmoth3 days agoVisiting Enthusiast61Views3likes4Comments🤓Xplan Hint: Model changing investment profiles in CALM
Did you know you can model changing investment profiles in Xtools+ using Life Stages? As clients move through different phases of life, their risk tolerance and investment needs shift. That’s where...andrew.wilson.04 days agoIress Contributor40Views2likes2Comments