Search code examples
githubgithub-search

How would I search Github issues created in the last x days?


Also asked here but in 2016 and with no working answer.

I'd like to search for issues created x number of days ago, but can only find how to search using actual (hardcoded, if you will) dates. For example, I want to search for issues created less than 7 days ago.

I've read through their search syntax documentation and cannot figure out a way to do that.


Solution

  • Currently, as mentioned in their Search Syntax docs:

    You can search for dates that are earlier or later than another date, or that fall within a range of dates, by using >, >=, <, <=, and range queries. Date formatting must follow the ISO8601 standard, which is YYYY-MM-DD (year-month-day).

    Meaning, unfortunately, they do not provide an out-of-the-box approach for you to do this relative searching.

    If you're using the UI search, you can use the sort to be by Newest, while if you're using the API/GraphQL, you will need to write a function to take in the x number of days, generate a compliant ISO8601 date and pass to your request.

    Not the answer you were hoping for, but I hope this helps clarify it.