JIRA JQL Date Searching: Using startOfDay() Instead of Now() for Precise Date Filtering

Nov 23, 2025 · Programming · 11 views · 7.8

Keywords: JIRA | JQL | Date Searching | startOfDay | Issue Filtering

Abstract: This article provides an in-depth exploration of using the startOfDay() function in JIRA JQL as an alternative to Now() for date-based searches. By comparing the differences between these two functions, it explains how startOfDay() addresses the limitations of time-based searching to achieve complete date range queries from 00:00 to 23:59. The article includes comprehensive code examples and practical application scenarios to help users master best practices for precise date filtering.

Challenges and Solutions in JQL Date Searching

In the JIRA issue management system, using JQL (JIRA Query Language) for date range searches is a common requirement. Many users initially encounter the Now() function, which returns the current date and timestamp. However, this time-based search approach has significant limitations.

Analysis of Now() Function Limitations

When using Now() with relative time offsets for searching, such as querying created < Now() AND created >= "-1d", the search results strictly depend on the specific time when the query is executed. If a user runs this query at 2:00 PM, the system will return issues created from 2:00 PM the previous day to 2:00 PM the current day. Similarly, if the same query is executed at 9:00 AM the next day, the results will cover the period from 9:00 AM that day to 9:00 AM the following day. This time sensitivity makes it impossible to achieve stable searches based on complete calendar days.

Introduction and Advantages of startOfDay() Function

Starting from JIRA version 4.3.x, the system introduced the startOfDay([offset]) function specifically to address the need for complete date-based searches. This function returns the start time (00:00:00) of the specified offset day, completely eliminating the interference of time components.

The basic syntax of the function is: startOfDay(offset), where the offset parameter supports various formats:

Practical Application Examples and Code Implementation

To search for all issues created today, use the following JQL query:

created >= startOfDay() AND created < startOfDay("+1d")

This query ensures the search range starts from 00:00:00 today and ends at 00:00:00 tomorrow, completely covering the 24-hour period of today.

For more complex scenarios, such as searching for issues created yesterday:

created >= startOfDay(-1) AND created < startOfDay()

The advantage of this method is that it provides consistent date range results regardless of when the query is executed, unaffected by the specific execution time.

Related Date Function Family

JIRA also provides other similar date functions to meet different needs:

Performance Optimization and Best Practices

When using date functions, it is recommended to follow these best practices:

  1. Prefer using the startOfDay() function family over time calculations based on Now()
  2. For fixed date ranges, consider using specific date values rather than relative offsets
  3. Combine with JIRA's index optimization to avoid frequent execution of complex date calculations on large datasets
  4. In team collaboration environments, standardize date search criteria to ensure result consistency

Conclusion

The startOfDay() function provides a more stable and reliable solution for JIRA JQL date searching. By eliminating time sensitivity, users can achieve precise searches based on complete calendar days, significantly improving the accuracy and predictability of query results. Combined with other date functions, complex query conditions can be constructed to meet various business requirements.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.