Hey guys,
I'm currently seeking help in a challenging task (at least for me) 
We have a Confluence space, that gets copied every year and where the copied space is then modified. These particular spaces also have the current year in its space keys, i.e. "wbk2022" for the new one, the one from last year would be "wbk2021". All pages in these spaces also include a user macro, that grab all relevant Jira issues, which relate to that space and where created that particular year.
Here's an example:
<ac:parameter ac:name="jqlQuery">project = WEITERBILD and "Titel des Training" ~ "$content.title" AND created >= 2021-01-01 AND created <= 2021-12-31</ac:parameter>
What we have to do every year, is copy that space with all its pages, create a copy of last years user macro and alter the date in that query. This is needed, because the "old" spaces need to be archived along with all referenced Jira issues of the corresponding year.
What I am trying right now is to extract the year from space key and use that information in my JQL query, therefore we would not need to create another user macro every year or alter all pages in the newly copied spaces.
I hope I was clear enough about my idea. Any help is highly appreciated 
Thanks and best regards
Sascha