AnsweredAssumed Answered

Velocity script - extracting date from today's date

Question asked by Phillip Wild on Nov 22, 2017
Latest reply on Nov 23, 2017 by Sanford Whiteman

We have a weekly newsletter than I'm automating as much as possible. One piece I'm trying to put in dynamically is what we call Lifetime Deposits. If a customer cancels a tour, they can use their deposit for another tour whenever they like. It never expires.

 

 

So what I'm trying to do is to insert a block into our newsletter for customers who have Lifetime Deposits reminding them that they have money on file. The catch is that I don't want to do this every week - it will bloat our newsletter and become repetitive.

 

 

In coding terms, I thought this could be solved by doing something like this. Our newsletter deploys on a Saturday each week, so why not check the day of the month, and if it's between 1-7, drop in the block for qualifying customers? Then it would only show once a month, and I would never need to update the block.

 

 

So I was thinking...set a calendar object using today's date, then extract the date portion of that, and see whether that integer is in the range 1-7.

 

 

The functionality here: Adding Days and Comparing Dates is a start....using the toCalendar function, but from there, I'm not sure how to extract the day of the month only. I could do something based on the string but that seems dangerous given you might extract "07" and then compare that to an integer.

 

 

Any thoughts?

 

 

Outcomes