Current location - Training Enrollment Network - Mathematics courses - How to use trunc () function in oracle?
How to use trunc () function in oracle?
1.TRUNC (date)

The date value truncated by the trunc function for the specified element.

The specific syntax format is as follows:

TRUNC (date [,time])

These include:

Date A date value.

Fmt date format, which will be truncated by the specified element format. Ignoring it will be truncated by the latest date.

The following is how to use this function:

TRUNC (so far ('24-11999 08: 00pm',' dd-mon-yyyy hh:mi am').

=' 1 1 24th of the month-1999 12:00:00 am'

TRUNC (so far ('24-1-199908: 37pm',' dd-mon-yyyy hh:mi am'),' hh' =' 24-1/kloc-.

Trunc (sysdate,' yyyy ')- Returns the first day of the year.

Trunc (sysdate,' mm ')- Returns the first day of the month.

Trunc (sysdate,' d ')- Returns the first day of the current week.

Trunc (sysdate,' DD ')- Returns the current year, month and day.

2.TRUNC (representative number)

TRUNC function returns the processed numerical value, and its working mechanism is very similar to that of ROUND function, except that it truncates all parts before or after the specified decimal.

Its specific grammatical format is as follows

TRUNC (number [,decimal])

These include:

The number of values to truncate.

Decimals indicate the number of digits that should be reserved after the decimal point. Optional, if omitted, all decimal parts will be truncated.

The following is how to use this function:

TRUNC(89.985,2)=89.98

TRUNC(89.985)=89

TRUNC(89.985,- 1)=80