# Find posts "solved" in specific month

**URL:** https://meta.discourse.org/t/find-posts-solved-in-specific-month/112674
**Category:** Data & reporting
**Tags:** solved, sql-query
**Created:** [March 27, 2019, 8:04am UTC](https://meta.discourse.org/t/find-posts-solved-in-specific-month/112674 "2019-03-27T08:04:26Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![user2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/user2/32/135592_2.png) [@user2](https://meta.discourse.org/u/user2)
#### Post date: [March 27, 2019, 8:04am UTC](https://meta.discourse.org/t/find-posts-solved-in-specific-month/112674/1 "2019-03-27T08:04:26Z")

</div>

I run discourse in a corporate environment as an order and documentation system. I use tags to choose whether an order (topic) is ongoing or completed. But I would need a way to identify orders that are completed in Mars, for example.  
Don’t feel like I want to use a tag for every month, eg tag: March19

Have limited visible tags in respective categories to facilitate the creation / maintenance of orders.

 ![image](https://global.discourse-cdn.com/meta/original/3X/0/7/074f13f78f47bc756fafed0a302a5ef886a0e190.png)

I had a thought of using hashtags that when something was finished, the person who delivered the order could comment on # march19 at the end of the thread so you could search on that tag. But does it not seem that hashtags work as they should on my discourse, the function may have been removed for the benefit of the tag system?

Are there any other plugins or ways to do this?  
Need ideas 🙂

---

<div class="post-metadata">

### Author: ![csmu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/csmu/32/124581_2.png) [@csmu](https://meta.discourse.org/u/csmu)
#### Post date: [March 28, 2019, 10:44am UTC](https://meta.discourse.org/t/find-posts-solved-in-specific-month/112674/2 "2019-03-28T10:44:28Z")

</div>

> [@user2](#):
>
> Are there any other plugins or ways to do this?

If you have admin privileges you could use the [data explorer](https://meta.discourse.org/t/32566?silent=true) plugin.

> [@Discourse Data Explorer](https://meta.discourse.org/t/data-explorer-plugin/32566):
>
> discourse2Summary Discourse [Data Explorer](https://meta.discourse.org/t/32566?silent=true) allows you to make SQL queries against your live database, allowing for up-to-the-minute stats reporting.open_bookInstall Guide This plugin is bundled with Discourse core. There is no need to install the plugin separately.information_source If you’re looking for examples or support for any custom queries, you can find lots of topics in our #Data & reporting category under the #sql-query tag. If there’s not one to suit your pa…

---

<div class="post-metadata">

### Author: ![user2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/user2/32/135592_2.png) [@user2](https://meta.discourse.org/u/user2)
#### Post date: [March 29, 2019, 9:46am UTC](https://meta.discourse.org/t/find-posts-solved-in-specific-month/112674/3 "2019-03-29T09:46:54Z")

</div>

Thanks, good suggestion but I am not so familiar with database inquiries so do not know if I even know where to start with it. Can anyone use / view the results of a request through [data explorer](https://meta.discourse.org/t/32566?silent=true) in any way? Would be good if everyone could sort out examples delivered things in March easily and not just administrators.

---

<div class="post-metadata">

### Author: ![csmu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/csmu/32/124581_2.png) [@csmu](https://meta.discourse.org/u/csmu)
#### Post date: [March 29, 2019, 10:03pm UTC](https://meta.discourse.org/t/find-posts-solved-in-specific-month/112674/4 "2019-03-29T22:03:05Z")

</div>

> [@user2](#):
>
> if I even know where to start

Here is a starting point.

```sql
-- [params]
-- int :months_ago = 1

WITH query_period AS
(SELECT date_trunc('month', CURRENT_DATE) - INTERVAL ':months_ago months' AS period_start,
                                                    date_trunc('month', CURRENT_DATE) - INTERVAL ':months_ago months' + INTERVAL '1 month' - INTERVAL '1 second' AS period_end)
select posts.*
from posts
inner join ( 
	select topic_id, value::int accepted_answer_post_id 
	from topic_custom_fields 
	where name = 'accepted_answer_post_id'
	order by name 
) solved_by_post
on posts.id = solved_by_post.accepted_answer_post_id
inner join query_period
on posts.created_at >= query_period.period_start
AND posts.created_at <= query_period.period_end
order by posts.created_at desc 

```

[solved-topics-in-month.dcquery (1).json](https://global.discourse-cdn.com/meta/original/3X/a/c/accd87e7ced0612d0378897168f15c87eb8c2d0d.json) (1.1 KB)

---

<div class="post-metadata">

### Author: ![csmu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/csmu/32/124581_2.png) [@csmu](https://meta.discourse.org/u/csmu)
#### Post date: [March 29, 2019, 10:06pm UTC](https://meta.discourse.org/t/find-posts-solved-in-specific-month/112674/5 "2019-03-29T22:06:38Z")

</div>

> [@user2](#):
>
> Would be good if everyone could sort out examples delivered things in March easily and not just administrators.

You could run a cron job at the start of each month to get the results and then create a new topic … ‘Orders Completed in March 2019’ with links to each result in the topic.
