I have a confiforms field with a date:
[entry.date] that I can format it in a plainview as [entry.date.formatDate(MMM yyyy)]
I want to list the month year and the following 11 months and the year for example if the current record is Aug 2024, I'd like to list Aug 2024, Sep 2024..... Jul 2025.
How can I do so? Ideally something like this:
[entry.date.addMonth(1).formatDate(MMM yyyy)]
[entry.date.addMonth(2).formatDate(MMM yyyy)]
Thanks,
May be something like this
[entry.date.formatDate(M).add(1).append( [entry.date.formatDate(yyyy)]).parseDate(M yyyy).formatDate(MMM yyyy)]
@Alex Medved _ConfiForms_ I have another field in the form called [entry.numberofmonths] that tells me how many months I'd like to display. Is it possible to do something like below to display all months? For example if the date is July 1, 2024, and the numberofmonths is 14, I'd like to display Jul 2024, ...... , Aug 2025. Thanks, again.
Plainview starts
---------------------------------------
#foreach ($i in [0..${numberofmonths}])
[entry.date.formatDate(M).add($i).append( [entry.date.formatDate(yyyy)]).parseDate(M yyyy).formatDate(MMM yyyy)]
#end
---------------------------------------
Plainview ends
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Generally I think it is all correct, what you are doing, but there must be some issue with a variable type
So, try doing this
#set($Integer = 0)
#foreach ($i in [0..$Integer.parseInt($numberofmonths)]) [entry.date.formatDate(M).add($i).append( [entry.date.formatDate(yyyy)]).parseDate(M yyyy).formatDate(MMM yyyy)] <br/> #end
To ensure the numberofmonths field is numeric for Velocity engine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
[entry.date.add(ms)]
...uses milliseconds and a month is something like 2 * 10^9 ms milliseconds, so it might be awkward to use that, but I would start there.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.