extract current year in Confluence page
Asked by Anna:

Hi there,

I have created Confluence page where all issues are grouped by month.

Jira macro with relative time is used for each month. For example, January will use the query below

issueFunction in linkedIssuesOfRecursiveLimited("project = XXX", 5) AND issuetype = Bug AND status != Cancelled AND resolved \>= startOfYear() and resolved \< startOfYear(1M)

I need to extract current year to display it in my page title. The whole reason behind this exercise is to have 1 page that will automatically refresh for each new year without need to edit JQL \& current Year value. Is there any way to accomplish this in Confluence without any plug ins and manual intervention to edit it on a yearly basis?

Thanking in advance!


Answers:
author: Nicolas Grossi
body: [@Anna](/t5/user/viewprofilepage/user-id/5337719) You might take a look at this documentation: <https://community.atlassian.com/t5/Confluence-questions/How-to-show-today-s-date-in-confluence-page/qaq-p/2156865>

Nicolas

comments: author: Anna
body: Hi Nicolas,

Thanks for the link. It looks like there is no way of extracting year dynamically in Confluence unless we use plug ins. I even checked confiForm elements but none of them met my expectations and also during export into pdf the value in confiForm disappears. I don't see any built in solution within Confluence at this moment.

Regards!


author: Alex Medved _ConfiForms_
body: [@Anna](/t5/user/viewprofilepage/user-id/5337719)

Could you please help us to understand what disappears from ConfiForms in PDF export? May be we can fix it...

Also, have you considered creating a user macro may be?

Some ideas: <https://wiki.vertuna.com/display/VERTUNA/Show+current+timestamp+on+the+page>

Alex


author: Anna
body: Hi Alex,

I inserted ConfiForm Field Definition (Field type = Text) and saved it. Then entered value 2024 in the page and exported in pdf. The entered value is not in pdf. I also noticed that pdf export pulls all values into pdf from dropdown (Field type = Dropdown), however, I am not my concern of these issues at this point.

I found another field type = Formula and tried to use NOW() function there and it doesn't display current time. I was thinking to format the date to get year. Is it possible to use this field just for pure date operation without referencing to any other field? I am not clear from the field description if this doable?

This is what the documentation tells about Formula field (<https://wiki.vertuna.com/display/CONFIFORMS/ConfiForms+Field+Types>)

This field type sets the value for the field based on an expression which can reference the record owner as \[owner\], a record modifier as \[modifier\]; and any record field as \[entry.FIELD_NAME\]. Important: this value is**calculated every time** an entry is updated (and created). See the "Calculated" type if the field should NOT recalculated on each edit. See [Supported math operators, formulas and functions](https://wiki.vertuna.com/display/CONFIFORMS/Supported+math+operators%2C+formulas+and+functions).


author: Alex Medved _ConfiForms_
body: So, in ConfiForms you have definitions and views... with one you can define/configure the form and with other you can view (and of course export) the data collected with the form


author: Anna
body: I don't need any dynamic entries in the form. My question was regarding a standalone field type = Formula. Is it possible to use it to pull current date, for example?


author: Alex Medved _ConfiForms_
body: There is no such thing as a "standalone field" - each field is part of the form. And in order to show something from the forms you need to save that "something" into the form. Be it the formula field or any other field


author: Anna
body: Hi Alex,

Finally, I found a very clumsy decision to display the current year through Office Excel macro in which I defined a formula =YEAR(NOW()) in A1 that returns value 2024.

Will this value change when we enter 2025 year or I need to reload the excel book on a yearly basis to get formula calculation updated?

P.S. I tested Excel macro and it is a snapshot of information. It should be manually updated or reloaded then the value will change. No need to reply. Thanks for support!


Tags: addon-com.vertuna.confluence.plugins.confiforms

confiforms

confluence

data-center

jira-data-center