Syntax for lastModified doesn't appear to do what I think it should.
Asked by James Lowe:

Hello, I did find <https://community.atlassian.com/t5/Confluence-questions/Search-Results-Macro-to-show-content-that-has-NOT-been-modified/qaq-p/139125> which showed the limitations of the 'search' macro, and that it was not on its own sophisticated enough to qury for things that were last modified \*before\* a certain date. The solution was to install an app called 'CQL Search'.

However I am able to enter search parameters within a 'markup' construct e.g

```
{search:lastModified=365d|maxLimit=50|type=page|spacekey=CS}
```

and this 'seems' to be a solution of sorts. However I either do not understand how the modifiers work or there is something I am missing as I no matter whethere i use '\>' or '\<' I seem to get the same results.

I am trying to use this method to show me pages that have not been modified for the last year (365 days).

I have tried

```
{search:lastModified>365|maxLimit=50|type=page|spacekey=CS}
```

and

```
{search:lastModified<365|maxLimit=50|type=page|spacekey=CS}
```

(just to make sure that it really was/was not working) and both of these markups seem to generate the same content for the search.

I know this did work once as we have recently moved from a local instance to a hosted instance and now this search term which previously seems to have used '-365d' is posting an error about the syntax being incorrect (implying it has changed).

Can someone point me to where I might be going wrong?

Thank you for your time.


Answers:
author: Shannon S
body: Hi James,

Welcome to Atlassian Community! Thanks for joining us. :smile:

You can refer to the Atlassian Developer documentation on how to use lastModified in a CQL query:

* [Advanced Searching Using CQL \> LastModified](https://developer.atlassian.com/cloud/confluence/advanced-searching-using-cql/#lastmodified)

> Search for content that was last modified on, before, or after a particular date (or date range).
>
> The search results will be relative to your configured time zone (which is by default the Confluence server's time zone)
>
> Use one of the following formats:
>
> `"yyyy/MM/dd HH:mm"` `"yyyy-MM-dd HH:mm"` `"yyyy/MM/dd"` `"yyyy-MM-dd"`

In your case, using 365 isn't valid because the CQL needs a particular date.

Here's an example of someone with a similar situation who was able to resolve it by supplying a date: [Solved: API query for lastModified returns every page](https://community.atlassian.com/t5/Confluence-questions/API-query-for-lastModified-returns-every-page/qaq-p/1654576)

I hope that helps! Let me know if you have any trouble.

Take care,

Shannon

comments: author: James Lowe
body: Hello Shannon, that helps a lot - thank you!

At least I understand the syntax better than I did before. A follow up question if I may? That the CQL syntax is suported in a 'markup' construct on a page, e.g. just pasting the query in the 'insert markup' macro. See attached for where I mean.

![Capture1.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/156760iF4D9B5F603D002DA/image-size/large?v=v2&px=999 "Capture1.PNG")

Thank you again.


author: Shannon S
body: Hi James,

I can certainly try to help. I've never inserted CQL in Markup before; what are you trying to accomplish here exactly? Are you inserting a particular macro?

I hope to hear from you soon!

Shannon


author: James Lowe
body: Hello Shannon, again thanks for your time.

What I am trying to is I think quite crude but effective.

Before we moved to our current hosted version of Confluence from our self-hosted older version (I don't know the numbers) the home page of this space I am interested in had what looked like a single one line query, created using markup, which confluence seems to turn into a 'macro' (as if it had been added as a search macro).

The query in this markup simply listed all pages in the same space that had not been modified for over a year - this allowed us to always be able to see which pages might need an update (or even deleted) because of their age without having to make a manual search using these often esoteric query language params.

Since the upgrade however this 'markup-cum-macro' now reports

*Error rendering macro 'search' : Invalid date period: -365d.*

So whatever the syntax was 'then' is not valid now.

Unfortuately it seems I cannot see what the original markup was as it gets converted to a macro 'as if' I had instered a 'search' macro directly from the built-in ones available to us.

Even though I can edit this macro directly, I cannot seem to create a query that does what I want - list only those pages that have been un-edited/last-updted for over a year.

I thought therefore I could try to just insert a new markup with a query and be done.

It has turned out a bit more complicated than I thought.

Sorry if this is something really obvious but I am just a general user with some access to edit pages and was trying to fix this myself.

I hope this makes more sense.


author: Shannon S
body: Hi James,

Thank you for providing those details. It looks like you were using the [Search Results macro](https://confluence.atlassian.com/doc/search-results-macro-139511.html) on your self-hosted version. Unfortunately, we ended support for that macro after Confluence 7.0, so this is why the markup syntax doesn't work anymore.

I discovered we have a feature request for that macro in Cloud:

* [CONFCLOUD-67827](https://jira.atlassian.com/browse/CONFCLOUD-67827) *Search Results Macro required in Confluence Cloud*

I'm not aware of a workaround for this, but it looks like you may be able to use an add-on for that, such as [Search Results for Confluence](https://marketplace.atlassian.com/apps/1223498/search-results-for-confluence?tab=overview&hosting=cloud).

I hope that helps, but let me know if you have any additional questions.

Take care,

Shannon


author: James Lowe
body: Shannon, that was helpful - even if it didn't help me immediately resolve the issue (I am a mere minion in my org with regard to administrating and managing our confluence install so I won't be able to implement the add-on suggested personally but will let those higher-up than I know) andI have at least put my interest (vote) in that FR and encourage anyone else reading this to do so as well.

The last update to that FR was Oct 2020 so I hope my addition bumps it up even if just a tiny bit.

Have fun and stay safe.

James


Tags: cloud

confluence-cloud

search