I'll look at this later. FYI there is a Jive bug that is causing posts to not show up for all people, thus I missed this until today.
1 of 1 people found this helpful
James, please use the syntax highlighter in Advanced Editor when posting code. Otherwise, it can be next to impossible to read. (Highlight as Java as it's the closest to Velocity.)
The direct cause of your error is a simple syntax error: you're missing a closing ) on the first line.
But even if you fix that, it doesn't look like you're going about this the right way...
- first, you must use timezone-aware code because even if you don't see that your Date objects are in a timezone, they always are
- second, the ComparisonDateTool.Comparison object (the result of a $date.difference() call) uses accessor methods like getDays(), not simple properties like days
I updated this seminal blog post with example code for your case: http://blog.teknkl.com/velocity-days-and-weeks/#howlongwillthepromolast
Remember to include the common code block at the top of the post, where you set the time zone as is essential for all datetime work.
Thank you very much! Really impressed with all of this.
I just ran a sample email, but unfortunately I got "The promo has already ended", the else portion of the if statement.
The date in the code itself is later than the date I ran the test, so I think it's having a problem picking up the calEndOfPromo variable.
Let me know if you need any more info, thank you again for all of your help!
Provide the whole token you're currently using, plus add these 2 lines at the end to dump the current dates
calNow: $date.format("yyyy-MM-dd'T'HH:mm:ss Z", $calNow) calEndOfPromo: $date.format("yyyy-MM-dd'T'HH:mm:ss Z", $calEndOfPromo)