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 |
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. |
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 |
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 |
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 |
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 |
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 |