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

yesterday date macro in Confluence

Gwenaël GRALL March 5, 2019

Hello,

I would to get the yesterday date from currentDate.

I need to get a specific hours

With Confluence's macro  I try to request on Jira

The request is like : project = "xx" AND created >= "2019-03-04 18:00" AND created <= "2019-03-05 18:00"

So I wrote this but $yesterday is missing:

## @param Project:title=project|type=string|required=true|desc=Key
#set($day2 = $action.dateFormatter.formatGivenString("yyyy-MM-dd 18:00", $content.currentDate))
  <ac:macro ac:name="jiraissues">
    <ac:parameter ac:name="title">;All Resolved Issues</ac:parameter>
    <ac:parameter ac:name="renderMode">static</ac:parameter>
    <ac:parameter ac:name="columns">Key,Created,Updated,Assignee,Status</ac:parameter>
    <ac:parameter ac:name="url">http://url.fr:8080/sr/jira.issueviews:searchrequest-rss/temp/SearchRequest.xml?jqlQuery=project+%3D+%22$paramProject%22+AND+created+%3E%3D+%22$day2%22</ac:parameter>
  </ac:macro>

Thanks for help

1 answer

1 accepted

1 vote
Answer accepted
Diego
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 7, 2019

Hello there Gwenaël! Great to have you here.

For you to get the yesterday date, we will need to set a variable with the calendar type and then subtract one with the .add method from the date type:

## @noparams
#set ($date=$action.dateFormatter.calendar)
$date.setTime($content.getCurrentDate())
$date.add(6, -1)
yesterday $action.dateFormatter.formatGivenString("yyyy-MM-dd", $date.time) <br>

You will be able to find more details on the add() method here:

Class Calendar - Field Manipulation

With dateFormatter you should be able to format the date as you see fit for your need. Here are some details on dateFormatter:

Oracle - dateFormatter

Let me know if this piece of information helps you!

Gwenaël GRALL March 8, 2019

Excelent !

This is what i wanted.
I have adapted my constraints with Adam Barilak solution for parametrable JQL request.

I have now a powerfull tool to request Jira to fix dates and add variables in reports

https://community.atlassian.com/t5/Confluence-questions/Using-template-variables-as-input-parameters-to-jira-gadget/qaq-p/189292#M31801

Thanks

Diego
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 8, 2019

Great to know that the code excerpt was useful Gwenaël!

Hope that the documentation also helps you out. If you ever need assistance again, come reach to the Community™!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events