Is it possible to add a filter that will only show items with a due date within the next 14 days?
Asked by Dena Ahlers:

I have a page created in Confluence but uses Macros from ConfiForms as well. We would like to display only items due within 14 days. Can anyone help with how this could be accomplished (if it can be).

Thank you in advance for any help,

Dena


Answers:
author: Alex Medved _ConfiForms_
body: Hi [@Dena Ahlers](/t5/user/viewprofilepage/user-id/5212357)

You can use the following filter (assuming the field to store dates is named "due"... but you can adjust accordingly)

    due:>=[entry._today] AND due:<=([entry._today]+1209600000)

where 1209600000 is 14 days in milliseconds

Alex

comments: author: Dena Ahlers
body: Thanks Alex!!


author: Dena Ahlers
body: Another question if you don't mind, I have this set up currently with a ConfiForms Field Definition (attached) Would I need to create a Rule definition to apply the filter or is there somewhere else it should be applied?

Thank you!

![Screenshot 2024-02-05 at 11.54.16?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/304432i6AD78CF3C49876F1/image-size/large?v=v2&px=999 "Screenshot 2024-02-05 at 11.54.16?AM.png")


author: Alex Medved _ConfiForms_
body: Was your question about the date field itself? About removing other dates from the date picker?


author: Dena Ahlers
body: I'm wondering where I would use the filter you provided. If I would need to create a different **field type** and where I would be entering the filter itself?   

Is that part of this Macro or would I be using a different macro? or use the macro along with a rule with the filter you provided? Trying to figure out what is the best process.


author: Alex Medved _ConfiForms_
body: My understanding of this question was that you want to filter collected data by the due date and show only the rows that match this range


author: Dena Ahlers
body: yup. but I am not sure where to put the filter that you provided.


author: Alex Medved _ConfiForms_
body: Every View macro in ConfiForms has this parameter, which you can use to specify a filtering expression

![filter2apply.png](https://community.atlassian.com/t5/image/serverpage/image-id/304452iACF89FC9915D13A6/image-dimensions/305x258?v=v2 "filter2apply.png")


author: Dena Ahlers
body: Got it!! thank you SOOOO much


author: Dena Ahlers
body: I'm sorry [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630) can you help me with one last thing? My field name is **fnAAGduedate for the Due Date label.**Would I then change the filter to

    fnAAGduedate:>=[entry._today] AND due:<=([entry._today]+1209600000)

I tried this but it did not return the right information so I am assuming I have it incorrect.


author: Alex Medved _ConfiForms_
body:     fnAAGduedate:>=[entry._today] AND fnAAGduedate:<=([entry._today]+1209600000)


author: Dena Ahlers
body: Thanks Alex, I did try that and it brings back all of the records, not just the records due in 14 days. This is what I had to ensure I didn't miss something.  
fnAAGduedate:\>=\[entry._today\] AND fnAAGduedate:\<=(\[entry._today\]+1209600000)

If I change it to date:\>=\[entry._today\] AND fnAAGduedate:\<=(\[entry._today\]+1209600000)

It returns 0 records, but I have at least 1 record that should meet the 14 day criteria. Do I need a today's date field? Thank you again for your help. If you need any other screenshots please let me know.


author: Alex Medved _ConfiForms_
body: Why do you want to change anything in this expression!?

I dont understand

If you have a fnAAGduedate that has a value within 14 days from today then you should see a record in the view.

Alex


author: Dena Ahlers
body: I don't necessarily want to change anything, I just want the right information to appear. Right now it shows all items from months ago to future due dates. I only want it to show items that are due within 14 days from the day they are looking at the page. I'm assuming I am missing something.  

You originally said to use this

    due:>=[entry._today] AND due:<=([entry._today]+1209600000)

Unfortunately this brings up 0 results.  

When I added the field name, then it brought up all fields with due dates ranging from 11-1-23 to 02-09-24

fnAAGduedate:\>=\[entry._today\] AND fnAAGduedate:\<=(\[entry._today\]+1209600000)   

I'm trying to figure out how to get this expression to work with how the page is configured. I'm wondering if it is confused on how the date is set up yy/mm/dd or if it needs an additional date field added. I'm sorry I don't know enough about Confluence to understand the best way to get this to work.

I attached a screenshot of how the date is displayed.![Screenshot 2024-02-06 at 9.57.31?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/304660i142AC0D71CC5E164/image-size/large?v=v2&px=999 "Screenshot 2024-02-06 at 9.57.31?AM.png")


author: Alex Medved _ConfiForms_
body: BTW, the date format yy/mm/dd means you have

YEAR **MINUTES** DAY

Why I have said "due" for the due date, is beacuase I had no idea how the field is named in your form...

That is why I have said
> (assuming the field to store dates is named "due"... but you can adjust accordingly)

Demo:

<http://recordit.co/BYcxTUJr7y>

Complete example:

```
<ac:structured-macro ac:macro-id="56e68d64-c768-4d28-a8a7-b0d572101355" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">form</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="3a2dbf1a-67a6-47c0-a959-2522a6c0a2b2" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<ac:structured-macro ac:macro-id="b83f0a1f-ebe3-4fdd-bb5d-40046697575d" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">t</ac:parameter>
<ac:parameter ac:name="fieldLabel">t</ac:parameter>
<ac:parameter ac:name="type">text</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="fa44c7ce-79da-44fc-a3be-afca2cd66e13" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">fnAAGduedate</ac:parameter>
<ac:parameter ac:name="fieldLabel">fnAAGduedate</ac:parameter>
<ac:parameter ac:name="type">date</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<h1>ALL</h1>
<ac:structured-macro ac:macro-id="fba09d71-8154-4682-8253-affa45299934" ac:name="confiform-table" ac:schema-version="1">
<ac:parameter ac:name="formName">form</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<h1>FILTERED </h1>
<p>as per <a class="" href="https://community.atlassian.com/t5/Confluence-questions/Is-it-possible-to-add-a-filter-that-will-only-show-items-with-a/qaq-p/2599072?utm_campaign=&amp;utm_content=post&amp;utm_medium=email&amp;utm_source=atlcomm#M291259">https://community.atlassian.com/t5/Confluence-questions/Is-it-possible-to-add-a-filter-that-will-only-show-items-with-a/qaq-p/2599072?utm_campaign=&amp;utm_content=post&amp;utm_medium=email&amp;utm_source=atlcomm#M291259</a>
</p>
<ac:structured-macro ac:macro-id="9dd9f791-858a-4244-ae24-a97e26d883a5" ac:name="confiform-table" ac:schema-version="1">
<ac:parameter ac:name="filter">fnAAGduedate:&gt;=[entry._today] AND fnAAGduedate:&lt;=([entry._today]+1209600000) </ac:parameter>
<ac:parameter ac:name="formName">form</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
```

Hope it helps...

Alex


author: Dena Ahlers
body: Thanks again Alex!

I found the issue I was having is that I am on an older version and

\[entry._today\] doesn't seem to be supported in our version. Changing that to \[today\] in the filter seemed to fix it


author: Alex Medved _ConfiForms_
body: Oh, it must be some very very old version of ConfiForms then :(


Tags: confiforms

confluence-server

server