User interfaces rarely show "2026-09-23 14:05:00" next to a comment or a notification; they show "3 days ago" or "in 2 hours". CALENDAR_SINCE, new in Oracle AI Database 26ai, returns that relative description of a date directly in SQL, in a long or a short form, so an application or report can display it without its own date logic.
Code for This Guide
The main example is in the examples/date-functions folder of the Oracle Database 26ai code repository on GitHub, with its output. The repository also has the NIMBUS sample schema in the setup/nimbus folder.
It comes from Oracle Database 26ai SQL and PL/SQL Book.
Syntax
Syntax:
calendar_since(dtexpr [, {'LONG' | 'SHORT'}])dtexpr is the date or timestamp to describe, compared with now. LONG, the default, returns phrases such as 3 days ago; SHORT returns compact forms such as 3d. Future dates are described too, as in In 2 hours.
Long and Short Forms
This query describes four dates relative to the current date: three days ago, forty-five days ago, four hundred days ago, and two hours ahead.
Example:
select d, calendar_since(d) as long_form, calendar_since(d, 'SHORT') as short_form from (values (sysdate - 3), (sysdate - 45), (sysdate - 400), (sysdate + 2/24)) t (d);
Output:
D LONG_FORM SHORT_FORM ______________ ______________ _____________ 23-SEP-2026 3 days ago 3d 12-AUG-2026 6 weeks ago 6w 22-AUG-2025 1 year ago 1y 26-SEP-2026 In 2 hours in 2h
The dates in the first column depend on when the query runs; the descriptions do not. The unit grows with the distance: seconds under two minutes, then minutes, hours, days, weeks, months, and years. 45 days becomes 6 weeks, and 400 days 1 year.
Use It in Queries
Because it is a SQL function, CALENDAR_SINCE can describe a column for every row, for example calendar_since(created_at) next to each review or support ticket, or in a report of last logins. The value is rounded to one unit, so it is meant for display, not for calculations; use DATEDIFF or date subtraction to compute.
Things to Know
- The result is computed at query time, so the same row reads differently tomorrow; do not store it.
- For sorting, order by the underlying date, never by the text.
Related Guides
Conclusion
CALENDAR_SINCE describes a date relative to now in words, such as 3 days ago or In 2 hours, or in a short form such as 3d. Use it to display ages and countdowns in reports and applications, and keep calculations on the underlying dates.
See my articles more often when you search Google.
