Table of Contents

Search

  1. Preface
  2. The Transformation Language
  3. Constants
  4. Operators
  5. Dates
  6. Functions
  7. Creating Custom Functions
  8. Custom Function API Reference
  9. POWERCENTERHELP

Transformation Language Reference

Transformation Language Reference

ROUND (Dates)

ROUND (Dates)

Rounds one part of a date. You can also use ROUND to round numbers.
This function can round the following parts of a date:
Year
Rounds the year portion of a date based on the month.
Month
Rounds the month portion of a date based on the day of the month.
Day
Rounds the day portion of the date based on the time.
Hour
Rounds the hour portion of the date based on the minutes in the hour.
Minute
Rounds the minute portion of the date based on the seconds.
Second
Rounds the second portion of the date based on the milliseconds.
Millisecond
Rounds the millisecond portion of the date based on the microseconds.
Microsecond
Rounds the microsecond portion of the date based on the nanoseconds.
The following table shows the conditions used by the ROUND expression and the return values:
Condition
Expression
Return Value
Month between January and June, function returns January 1 of the same year and sets the time to 00:00:00.000000000.
ROUND(TO_DATE('04/16/1998 8:24:19','MM/DD/YYYY HH24:MI:SS'),'YY')
01/01/1998 00:00:00.000000000
Month between July and December, function returns January 1 of next year and sets the time to 00:00:00.000000000.
ROUND(TO_DATE('07/30/1998 2:30:55','MM/DD/YYYY HH24:MI:SS'),'YY')
01/01/1999 00:00:00.000000000
Day of the month between 1 and 15, function returns the first day of the input month and sets the time to 00:00:00.000000000.
ROUND(TO_DATE('04/15/1998 8:24:19','MM/DD/YYYY HH24:MI:SS'),'MM')
04/01/1998 00:00:00.000000000
Day of the month between 16 and the last day of the month, function returns the first day of the next month and sets the time to 00:00:00.000000000.
ROUND(TO_DATE('05/22/1998 10:15:29','MM/DD/YYYY HH24:MI:SS'),'MM')
06/01/1998 00:00:00.000000000
Time between 00:00:00 (12 a.m.) and 11:59:59 a.m., function returns the current date and sets the time to 00:00:00.000000000 (12 a.m.).
ROUND(TO_DATE('06/13/1998 2:30:45','MM/DD/YYYY HH24:MI:SS'),'DD')
06/13/1998 00:00:00.000000000
Time 12:00:00 (12 p.m.) or later, function rounds the date to the next day and sets the time to 00:00:00.000000000 (12 a.m.).
ROUND(TO_DATE('06/13/1998 22:30:45','MM/DD/YYYY HH24:MI:SS'),'DD')
06/14/1998 00:00:00.000000000
Minute portion of time between 0 and 29 minutes, function returns the current hour and sets minutes, seconds, milliseconds, and nanoseconds to 0.
ROUND(TO_DATE('04/01/1998 11:29:35','MM/DD/YYYY HH24:MI:SS'),'HH')
04/01/1998 11:00:00.000000000
Minute portion of the time 30 or greater, function returns the next hour and sets minutes, seconds, milliseconds, and nanoseconds to 0.
ROUND(TO_DATE('04/01/1998 13:39:00','MM/DD/YYYY HH24:MI:SS'),'HH')
04/01/1998 14:00:00.000000000
Time between 0 and 29 seconds, function returns the current minute and sets seconds, milliseconds, and nanoseconds to 0.
ROUND(TO_DATE('05/22/1998 10:15:29','MM/DD/YYYY HH24:MI:SS'),'MI')
05/22/1998 10:15:00.000000000
Time between 30 and 59 seconds, function returns the next minute and sets seconds, milliseconds, and nanoseconds to 0.
ROUND(TO_DATE('05/22/1998 10:15:30','MM/DD/YYYY HH24:MI:SS'),'MI')
05/22/1998 10:16:00.000000000
Time between 0 and 499 milliseconds, function returns the current second and sets milliseconds to 0.
ROUND(TO_DATE('05/22/1998 10:15:29.499','MM/DD/YYYY HH24:MI:SS.MS'),'SS')
05/22/1998 10:15:29.000000000
Time between 500 and 999 milliseconds, function returns the next second and sets milliseconds to 0.
ROUND(TO_DATE('05/22/1998 10:15:29.500','MM/DD/YYYY HH24:MI:SS.MS'),'SS')
05/22/1998 10:15:30.000000000
Time between 0 and 499 microseconds, function returns the current millisecond and sets microseconds to 0.
ROUND(TO_DATE('05/22/1998 10:15:29.498125','MM/DD/YYYY HH24:MI:SS.US'),'MS')
05/22/1998 10:15:29.498000000
Time between 500 and 999 microseconds, function returns the next millisecond and sets microseconds to 0.
ROUND(TO_DATE('05/22/1998 10:15:29.498785','MM/DD/YYYY HH24:MI:SS.US'),'MS')
05/22/1998 10:15:29.499000000
Time between 0 and 499 nanoseconds, function returns the current microsecond and sets nanoseconds to 0.
ROUND(TO_DATE('05/22/1998 10:15:29.498125345','MM/DD/YYYY HH24:MI:SS.NS'),'US')
05/22/1998 10:15:29.498125000
Time between 500 and 999 nanoseconds, function returns the next microsecond and sets nanoseconds to 0.
ROUND(TO_DATE('05/22/1998 10:15:29.498125876','MM/DD/YYYY HH24:MI:SS.NS'),'US')
05/22/1998 10:15:29.498126000

Syntax

ROUND(
date
[,
format
] )
The following table describes the arguments for this command:
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 port with a Date/Time datatype.
NULL if you pass a null value to the function.

Examples

The following expressions round the year portion of dates in the DATE_SHIPPED port:
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:00.000000000AM
Apr 19 1998 1:31:20PM
Jan 1 1998 12:00:00.000000000AM
Dec 20 1998 3:29:55PM
Jan 1 1999 12:00:00.000000000AM
NULL
NULL
The following expressions round the month portion of each date in the DATE_SHIPPED port:
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:00.000000000AM
Apr 19 1998 1:31:20PM
May 1 1998 12:00:00.000000000AM
Dec 20 1998 3:29:55PM
Jan 1 1999 12:00:00.000000000AM
NULL
NULL
The following expressions round the day portion of each date in the DATE_SHIPPED port:
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:00.000000000AM
Apr 19 1998 1:31:20PM
Apr 20 1998 12:00:00.000000000AM
Dec 20 1998 3:29:55PM
Dec 21 1998 12:00:00.000000000AM
Dec 31 1998 11:59:59PM
Jan 1 1999 12:00:00.000000000AM
NULL
NULL
The following expressions round the hour portion of each date in the DATE_SHIPPED port:
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:00.000000000AM
Apr 19 1998 1:31:20PM
Apr 19 1998 2:00:00.000000000PM
Dec 20 1998 3:29:55PM
Dec 20 1998 3:00:00.000000000PM
Dec 31 1998 11:59:59PM
Jan 1 1999 12:00:00.000000000AM
NULL
NULL
The following expression rounds the minute portion of each date in the DATE_SHIPPED port:
ROUND( DATE_SHIPPED, 'MI' )
DATE_SHIPPED
RETURN VALUE
Jan 15 1998 2:10:30AM
Jan 15 1998 2:11:00.000000000AM
Apr 19 1998 1:31:20PM
Apr 19 1998 1:31:00.000000000PM
Dec 20 1998 3:29:55PM
Dec 20 1998 3:30:00.000000000PM
Dec 31 1998 11:59:59PM
Jan 1 1999 12:00:00.000000000AM
NULL
NULL