Function Reference > Functions > ROUND (Dates)
  

ROUND (Dates)

Rounds one part of a date. You can also use ROUND to round numbers.
This functions can round the following parts of a date:

Syntax

ROUND( date [,format] )
Argument
Required/
Optional
Description
date
Required
Date/Time datatype. You can nest TO_DATE to convert strings to dates before rounding.
format
Optional
Enter a valid format string. This is the portion of the date that you want to round. You can round only one portion of the date. If you omit the format string, the function rounds the date to the nearest day.
Return Value
Date with the specified part rounded. ROUND returns a date in the same format as the source date. You can link the results of this function to any column with a Date/Time datatype.
NULL if you pass a null value to the function.

Example

The following expressions round the year portion of dates in the DATE_SHIPPED column:
ROUND( DATE_SHIPPED, 'Y' )
ROUND( DATE_SHIPPED, 'YY' )
ROUND( DATE_SHIPPED, 'YYY' )
ROUND( DATE_SHIPPED, 'YYYY' )
DATE_SHIPPED
RETURN VALUE
Jan 15 1998 2:10:30AM
Jan 1 1998 12:00:00AM
Apr 19 1998 1:31:20PM
Jan 1 1998 12:00:00AM
Dec 20 1998 3:29:55PM
Jan 1 1999 12:00:00AM
NULL
NULL
The following expressions round the month portion of each date in the DATE_SHIPPED column:
ROUND( DATE_SHIPPED, 'MM' )
ROUND( DATE_SHIPPED, 'MON' )
ROUND( DATE_SHIPPED, 'MONTH' )
DATE_SHIPPED
RETURN VALUE
Jan 15 1998 2:10:30AM
Jan 1 1998 12:00:00AM
Apr 19 1998 1:31:20PM
May 1 1998 12:00:00AM
Dec 20 1998 3:29:55PM
Jan 1 1999 12:00:00AM
NULL
NULL
The following expressions round the day portion of each date in the DATE_SHIPPED column:
ROUND( DATE_SHIPPED, 'D' )
ROUND( DATE_SHIPPED, 'DD' )
ROUND( DATE_SHIPPED, 'DDD' )
ROUND( DATE_SHIPPED, 'DY' )
ROUND( DATE_SHIPPED, 'DAY' )
DATE_SHIPPED
RETURN VALUE
Jan 15 1998 2:10:30AM
Jan 15 1998 12:00:00AM
Apr 19 1998 1:31:20PM
Apr 20 1998 12:00:00AM
Dec 20 1998 3:29:55PM
Dec 21 1998 12:00:00AM
Dec 31 1998 11:59:59PM
Jan 1 1999 12:00:00AM
NULL
NULL
The following expressions round the hour portion of each date in the DATE_SHIPPED column:
ROUND( DATE_SHIPPED, 'HH' )
ROUND( DATE_SHIPPED, 'HH12' )
ROUND( DATE_SHIPPED, 'HH24' )
DATE_SHIPPED
RETURN VALUE
Jan 15 1998 2:10:31AM
Jan 15 1998 2:00:00AM
Apr 19 1998 1:31:20PM
Apr 19 1998 2:00:00PM
Dec 20 1998 3:29:55PM
Dec 20 1998 3:00:00PM
Dec 31 1998 11:59:59PM
Jan 1 1999 12:00:00AM
NULL
NULL
The following expression rounds the minute portion of each date in the DATE_SHIPPED column:
ROUND( DATE_SHIPPED, 'MI' )
DATE_SHIPPED
RETURN VALUE
Jan 15 1998 2:10:30AM
Jan 15 1998 2:11:00AM
Apr 19 1998 1:31:20PM
Apr 19 1998 1:31:00PM
Dec 20 1998 3:29:55PM
Dec 20 1998 3:30:00PM
Dec 31 1998 11:59:59PM
Jan 1 1999 12:00:00AM
NULL
NULL