Menu
Amazon Redshift
Database Developer Guide (API Version 2012-12-01)

TRUNC Date Function

Truncates a time stamp and returns a date.

Syntax

Copy
TRUNC(timestamp)

Arguments

timestamp

A timestamp column or an expression that implicitly converts to a time stamp.

To return a time stamp value with 00:00:00 as the time, cast the function result to a TIMESTAMP.

Return Type

DATE

Examples

Return the date portion from the result of the SYSDATE function (which returns a time stamp):

Copy
select sysdate; timestamp ---------------------------- 2011-07-21 10:32:38.248109 (1 row) select trunc(sysdate); trunc ------------ 2011-07-21 (1 row)

Apply the TRUNC function to a TIMESTAMP column. The return type is a date.

Copy
select trunc(starttime) from event order by eventid limit 1; trunc ------------ 2008-01-25 (1 row)