[Oracle] [32] taken TRUNC

Preface:

Expressions: TRUNC (param, [fmt])

Meaning: the value param field taken in accordance with the rules fmt

text:

1, the date

SELECT the trunc (SYSDATE, ' YYYY ' ) from Dual - the first day of the year 
SELECT the trunc (SYSDATE, ' mm ' ) from Dual - first of the month 
SELECT the trunc (SYSDATE, ' dd ' ) from Dual - Current time (accurate to days) 
SELECT the trunc (SYSDATE, ' D ' ) from Dual - on the first day of the current week 
SELECT the trunc (SYSDATE, ' HH ' ) from Dual- current time (to the nearest hour) 
SELECT the trunc (SYSDATE, ' mi The ' ) from Dual - current time (to the nearest minute, not accurate to the second)

 2, digital

- 123.4 behind the decimal point, not rounded 
SELECT the trunc ( 123.458 , . 1 ) from Dual; 

- 120 in front of the decimal point a 
SELECT the trunc ( 123.458 , - . 1 ) from Dual

Reference blog:

Usage Oracle trunc () function - Code changes life - blog Park
https://www.cnblogs.com/suding1188/archive/2013/01/06/2848067.html

Guess you like

Origin www.cnblogs.com/huashengweilong/p/11355204.html
Recommended