Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Confiforms: how to add a month to a date

Patrick Liang September 11, 2024

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,

2 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
3 votes
Answer accepted
Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 11, 2024

May be something like this

[entry.date.formatDate(M).add(1).append( [entry.date.formatDate(yyyy)]).parseDate(M yyyy).formatDate(MMM yyyy)]
Patrick Liang September 11, 2024

This works perfectly!!! Again nothing can stop Alex to provide a working solution. lol,

Much appreciated.

Patrick Liang September 11, 2024

@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

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 11, 2024

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

Like Patrick Liang likes this
1 vote
Jim Knepley - ReleaseTEAM
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
September 11, 2024
[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.

Patrick Liang September 11, 2024

Adding ms won't work because every month has different number of days. but thanks for your answer.

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events