DATECEILING function [Date and time]

Function

Calculates a new date, time, or datetime value by increasing the provided value up to the nearest larger value of the specified multiple with the specified granularity.

Syntax

DATECEILINGdate-part, datetime-expression [,multiple -expression])

Parameters

date part The date part to be added to the date.

The following date parts are not compatible with DATECEILING:

For a complete listing of date parts, see Date part values.

datetime-expression The date, time, or date-time expression containing the value you are evaluating.

multiple-expression (Optional). A nonzero positive integer value expression specifying how many multiples of the units specified by the date_part parameter to use within the calculation. For example, you can use multiple-expression to specify that you want to regularize your data to 10-minute intervals. Note that if multiple-expression evaluates to zero, evaluates to a negative number, or is an explicit NULL constant, Sybase IQ generates an error. If this multiple-expression evaluates to a NULL, then the function result is NULL.

Example

This returns the value August 13, 2009 10:40.00.000AM:

SELECT DATECEILING( MI, 'August 13, 2009, 10:32.00.132AM', 10) FROM iq_dummy

Usage

This function calculates a new date, time, or datetime value by increasing the provided value up to the nearest larger value with the specified granularity. If you include the optional multiple-expression parameter, then the function increases the date and time up to the nearest specified multiple of the specified granularity.

The data type of the calculated date and time matches the data type of the multiple-expression parameter.

If you specify a multiple-expression for the millisecond, second, minute, or hour date parts, IQ assumes that the multiple applies from the start of the next larger unit of granularity:

For example, if you specify a multiple of two minutes, IQ applies two-minute intervals starting at the current hour.

For the millisecond, second, minute, and hour date parts, specify a multiple-expression value that divides evenly into the range of the specified date part:

If you specify a multiple-expression for the day, week, month, quarter, or year date parts, IQ assumes the intervals started at the smallest date value (0000-01-01), smallest time value (00:00:00.000000), or smallest date-time value (0000-01-01.00:00:00.000000). For example, if you specify a multiple of 10 days, then Sybase IQ calculates 10-day intervals starting at 0000-01-01.

For the day, week, month, quarter, or year date parts, you need not specify a multiple that divides evenly into the next larger unit of time granularity.

If IQ rounds to a multiple of the week date part, the date value is always Sunday.

Standards and compatibility