Searching for posts created within a specific timeframe

:bookmark: This guide explains how to use Discourse’s search functionality to find posts created within a certain timeframe.

:person_raising_hand: Required user level: All users

Discourse’s search interface allows you to scope your searches to specific date ranges using the before and after search clauses. This feature can be particularly useful when you need to find posts from a certain period or within a specific timeframe.

Using the before and after clauses

The before and after clauses accept the following date formats:

  • Full date (YYYY-MM-DD)
  • Year and month (YYYY-MM)
  • Year only (YYYY)
  • Name of month (full or abbreviated, e.g., june or jun)
  • Day of week (e.g., friday)
  • yesterday
  • Number of days ago (1–999, e.g., 7 means 7 days ago)

Here are some examples to help you understand how to use these clauses:

  1. before:june hashtag

    • This will find posts with the term “hashtag” that were created before last June.
  2. before:2014 category:bug order:latest

    • This search will return posts in the “bug” category created before 2014, ordered by the most recent first.
  3. after:friday broken

    • This will find posts containing the word “broken” that were created after the beginning of the week containing last Friday.
  4. after:2016-01-12 before:2016-01-20 happy

    • This search will return posts containing the word “happy” that were created between January 12, 2016, and January 20, 2016.
  5. after:june before:july in:first composer

    • This will search for the word “composer” in the first post of topics created between last June and last July.
  6. after:10 before:8 thing

    • This search will find posts containing the word “thing” that were created between 8 and 10 days ago.
  7. after:yesterday status update

    • This will find posts containing the words “status update” that were created since yesterday.

Important notes

  • All dates are interpreted in the server’s configured time zone (UTC by default).
  • The search uses the beginning of the day (00:00:00) as the start time for any period.
  • The filter applies to the created_at date of posts, not the date a topic was created.
  • If you need to filter based on topic creation date, use the in:first clause in your search query.

Limitations

Currently, the search function does not support sub-day resolution without specifying a full qualified date. For example, searching for posts that are at least 2 hours old using before:2h or before:120m is not possible.

:bulb: If you need more precise time-based filtering (e.g., posts older than 2 hours), consider using a Data Explorer report. This can be especially useful for support teams who need to give community members a chance to answer questions before intervening.

Last edited by @hugh 2024-07-02T09:45:57Z

Last checked by @hugh 2024-07-02T09:46:04Z

Check documentPerform check on document:
13개의 좋아요

after: 및 before: 검색에 사용할 수 있는 단위에는 어떤 것들이 있나요? 기본값이 '일(day)'인 것을 확인했는데, 전체 날짜를 지정하지 않고도 하루 미만의 해상도로 검색할 수 있을까요?

구체적인 사용 사례를 말씀드리면, 최소 2시간 이상 지난 게시물을 반환하는 것입니다. 2시간 전에 생성된 주제를 선택하기 위해 in:first를 사용할 계획입니다.

before:2h, before:120m, before:02:00:00을 시도해 보았지만 모두 작동하지 않았습니다.

그 이유는: 지원 팀이 도움을 요청하는 요청에 개입하여 해결을 시도하기 전에 커뮤니티 구성원들이 질문에 답할 기회를 주고 싶기 때문입니다.

1개의 좋아요

하루보다 짧은 기간 동안 필요한 경우, 지원 팀과 공유할 수 있는 데이터 탐색기 보고서가 더 적합한 옵션일 수 있습니다. 이렇게 하면 사이드바에 추가해 필요할 때마다 바로 실행할 수 있습니다. :+1:

3개의 좋아요