Ceil


Ceil(x, digits, dateUnit)

Ceil(x) returns the smallest integer that is greater than or equal to «x».

Ceil(174.001) → 175
Ceil(-89.95) → -89

When the optional «digits» parameter is given, cuts the number off at «digits» to the right of the decimal, returning the smallest multiple of 10-«digits» that is equal to or larger than «x».

Ceil( 3.141592, 2) → 3.150000
Ceil(-3.141592, 2) → -3.140000
Ceil( 3.141592, 5) → 3.141600

«digits» may also be negative, in which case the least significant -«digits» digits will be '0':

Ceil(123456.789, -1) → 123460.00
Ceil(123456,789, -4) → 130000.00

If you specify the «dateUnit» parameter, Ceil rounds a date-time number upward to the earliest date-time at the «dateUnit» increment that is equal to or comes after the date-time specified in «x». For example, you can round up to the beginning of the following year, quarter, or month, or to the beginning (meaning midnight) of the next weekday, day, or up to the next hour, minute or second. The value you pass to «dateUnit» must be one of the following: 'Y', 'year', 'Q', 'quarter', 'M', 'month', 'WD', 'weekday', 'D', 'day', 'h', 'hour', 'm', 'minute', 's', or 'second'. Note that 'M' (for Month) and 'm' (for minute) are case sensitive.

Ceil(MakeDate(2010, 8, 8), dateUnit: 'Y') → 2011-Jan-1
Ceil(MakeDate(2010, 8, 8), dateUnit: 'Q') → 2010-Oct-1
Ceil(MakeDate(2010, 8, 8), dateUnit: 'M') → 2010-Sep-1
Ceil(MakeDate(2010, 8, 1), dateUnit: 'M') → 2010-Aug-1
Ceil(MakeDate(2010, 8, 1)+MakeTime(0, 0, 1), dateUnit: 'M') → 2010-Sep-1

Notice in the last example that if we are even one second past midnight of Aug 1st, it rounds to the beginning of the next month.

Number Format

The Ceil, Round and Floor functions all cut a number off to the indicated number of decimal places, but note that this is separate from the number format used to display the number. The number format setting controls how many digits are shown when displaying numbers, such as in an edit or result table. For example, after rounding to 4 decimal places, a number may be 2.3456, but if your number format is set to fixed point with 2 digits, this would display as 2.35.

To see the full effect of the Ceil function, set the number format to a large number of digits.

See Also

Comments


You are not allowed to post comments.