Function Reference > Functions > TRUNC (Dates)
  

TRUNC (Dates)

Truncates dates to a specific year, month, day, hour, or minute. You can also use TRUNC to truncate numbers.
You can truncate the following date parts:

Syntax

TRUNC( date [,format] )
Argument
Required/
Optional
Description
date
Required
Date/Time datatype. The date values you want to truncate. You can enter any valid expression that evaluates to a date.
format
Optional
Enter a valid format string. The format string is not case sensitive. If you omit the format string, the function truncates the time portion of the date, setting it to 00:00:00.

Return Value

Date.
NULL if a value passed to the function is NULL.

Example

The following expressions truncate the year portion of dates in the DATE_SHIPPED column:
TRUNC( DATE_SHIPPED, 'Y' )
TRUNC( DATE_SHIPPED, 'YY' )
TRUNC( DATE_SHIPPED, 'YYY' )
TRUNC( 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
Jun 20 1998 3:50:04AM
Jan 1 1998 12:00:00AM
Dec 20 1998 3:29:55PM
Jan 1 1998 12:00:00AM
NULL
NULL
The following expressions truncate the month portion of each date in the DATE_SHIPPED column:
TRUNC( DATE_SHIPPED, 'MM' )
TRUNC( DATE_SHIPPED, 'MON' )
TRUNC( 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
Apr 1 1998 12:00:00AM
Jun 20 1998 3:50:04AM
Jun 1 1998 12:00:00AM
Dec 20 1998 3:29:55PM
Dec 1 1998 12:00:00AM
NULL
NULL
The following expressions truncate the day portion of each date in the DATE_SHIPPED column:
TRUNC( DATE_SHIPPED, 'D' )
TRUNC( DATE_SHIPPED, 'DD' )
TRUNC( DATE_SHIPPED, 'DDD' )
TRUNC( DATE_SHIPPED, 'DY' )
TRUNC( 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 19 1998 12:00:00AM
Jun 20 1998 3:50:04AM
Jun 20 1998 12:00:00AM
Dec 20 1998 3:29:55PM
Dec 20 1998 12:00:00AM
Dec 31 1998 11:59:59PM
Dec 31 1998 12:00:00AM
NULL
NULL
The following expressions truncate the hour portion of each date in the DATE_SHIPPED column:
TRUNC( DATE_SHIPPED, 'HH' )
TRUNC( DATE_SHIPPED, 'HH12' )
TRUNC( 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 1:00:00PM
Jun 20 1998 3:50:04AM
Jun 20 1998 3:00:00AM
Dec 20 1998 3:29:55PM
Dec 20 1998 3:00:00PM
Dec 31 1998 11:59:59PM
Dec 31 1998 11:00:00AM
NULL
NULL
The following expression truncates the minute portion of each date in the DATE_SHIPPED column:
TRUNC( DATE_SHIPPED, 'MI' )
DATE_SHIPPED
RETURN VALUE
Jan 15 1998 2:10:30AM
Jan 15 1998 2:10:00AM
Apr 19 1998 1:31:20PM
Apr 19 1998 1:31:00PM
Jun 20 1998 3:50:04AM
Jun 20 1998 3:50:00AM
Dec 20 1998 3:29:55PM
Dec 20 1998 3:29:00PM
Dec 31 1998 11:59:59PM
Dec 31 1998 11:59:00PM
NULL
NULL