This shows you the differences between two versions of the page.
dev:sql:functions:trunc [2009/12/07 14:38] tdo created |
dev:sql:functions:trunc [2016/06/28 22:38] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | {{page>:top_add&nofooter&noeditbtn}} | ||
- | <html><div align="center"><span style="color:red">DRAFT</span></div></html> | ||
- | ====== Omnidex SQL Function: $TRUNC ====== | ||
- | {{page>:sql_bar&nofooter&noeditbtn}} | ||
- | ===== Description ===== | ||
- | The $TRUNC function returns a numeric expression truncated to a specified number of digits to the right of the decimal point. | ||
- | If the value specified by n is positive and longer than the digits after the decimal point, 0 is added after the fraction digits. | ||
- | |||
- | If the value specified by n is negative and larger than or equal to the digits before the decimal point, 0 is returned. | ||
- | |||
- | When a numeric expression is truncated, the trailing digits are simply dropped off. The return value is not rounded in any way. | ||
- | |||
- | |||
- | ===== Syntax ===== | ||
- | TRUNC(expression [,n]) | ||
- | |||
- | expression | ||
- | Required. The numerical expression that is to be truncated. | ||
- | |||
- | n | ||
- | Optional. n is an integer indicating the number of digits to display after the decimal point. | ||
- | ===== Example ===== | ||
- | ==== Example 1 ==== | ||
- | $TRUNC(123.4545, 2) result: 123.45 | ||
- | |||
- | $TRUNC(123.4545, -2) result: 100 | ||
- | |||
- | $TRUNC(123.9994, 3) result: 123.999 | ||
- | |||
- | $TRUNC(123.9995, 3) result: 123.999 | ||
- | {{page>:bottom_add&nofooter&noeditbtn}} |