Oracle SQL Date Filters for Monthly Reports

Oracle SQL · Reporting

Include the last daydown to the last second.

A report for November should include records from November 30 at 11:59 p.m. Here’s how I write date filters in Oracle SQL so those rows make it into the report.

Why records disappear

Oracle’s DATE type stores a date and a time through the second. The literal DATE '2026-11-30' represents November 30 at midnight. If you use it as the upper boundary with <=, a case opened later that day falls outside the range.

Use the next day as the cutoff

Include the start of November with >= and stop before December 1 with <. This is a half-open range. The following self-contained query runs on three illustrative rows.

Run this in Oracle SQL
WITH demo_cases (case_id, opened_at) AS (
  SELECT 101, DATE '2026-11-01' FROM dual
  UNION ALL
  SELECT 102, DATE '2026-12-01' - 1 / 86400 FROM dual
  UNION ALL
  SELECT 103, DATE '2026-12-01' FROM dual
)
SELECT case_id, opened_at
FROM demo_cases
WHERE opened_at >= DATE '2026-11-01'
  AND opened_at <  DATE '2026-12-01'
ORDER BY opened_at;

Expected result. Cases 101 and 102 are included. Case 103 starts the next reporting period.

Test the boundaries

Expected results for the November 2026 sample
Case opened atIn November report?
Yes
Yes
No

For a report with user-selected dates, pass the inclusive start and exclusive end as bind variables of the appropriate date or timestamp type. Test these boundary cases against a representative dataset before release.

Read more in the Oracle SQL Language Reference on date literals.

BishoyiFy | Web Design & Oracle PL/SQL Consulting & GRC

BishoyiFy is a Navi Mumbai-based web development and Oracle PL/SQL consultancy. I build mobile-friendly business websites with enquiry forms and WhatsApp integration, and help software teams with PL/SQL development, SQL performance tuning, reporting, and GRC workflow enhancements.

Project enquiries

Tell me what you need.

Share a short brief, your preferred timeline, and a budget range if you have one. I’ll reply by email to discuss the scope.

I use these details to respond to your enquiry. Please leave out passwords, database credentials, and confidential records.