Skip to main content
← PL/SQL Topics

String & Data Functions

Explain ROUND and TRUNC for numbers and dates

ROUND and TRUNC

ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated

With numbers they round/truncate to a decimal place; with dates they round/truncate to a unit like month or day.

How it works

ROUND(n, d) rounds to d decimal places (negative d rounds to tens/hundreds); TRUNC(n, d) chops without rounding. ROUND(date, 'fmt') and TRUNC(date, 'fmt') snap to a calendar unit: 'DD' (midnight — the usual way to drop a time), 'MM' (first of month), 'YYYY' (first of year), 'IW' (ISO week start), 'HH24' (top of hour). TRUNC(SYSDATE) is the idiom for 'today at 00:00'.

How it works
SELECT ROUND(1234.5678, 2)          AS n_round,   -- 1234.57
       TRUNC(1234.5678, 2)          AS n_trunc,   -- 1234.56
       ROUND(1250, -2)             AS n_round_h,  -- 1300
       TRUNC(SYSDATE)              AS today_midnight,
       TRUNC(SYSDATE, 'MM')       AS first_of_month
  FROM dual;

Related questions

GroundingGenerated

Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.

Have a follow-up, or a different question?

Continue in Ask Oracle AI