Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

TRUNC function

Focus mode
TRUNC function - Amazon Redshift

Truncates a TIMESTAMP and returns a DATE.

This function can also truncate a number. For more information, see TRUNC function.

Syntax

TRUNC(timestamp)

Arguments

timestamp

A column of data type TIMESTAMP or an expression that implicitly evaluates to a TIMESTAMP type.

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

Return type

DATE

Examples

The following example returns the date portion from the result of the SYSDATE function (which returns a timestamp).

SELECT SYSDATE; +----------------------------+ | timestamp | +----------------------------+ | 2011-07-21 10:32:38.248109 | +----------------------------+ SELECT TRUNC(SYSDATE); +------------+ | trunc | +------------+ | 2011-07-21 | +------------+

The following example applies the TRUNC function to a TIMESTAMP column. The return type is a date.

SELECT TRUNC(starttime) FROM event ORDER BY eventid LIMIT 1; +------------+ | trunc | +------------+ | 2008-01-25 | +------------+

The following example returns a timestamp value with 00:00:00 as the time by casting the TRUNC function result to a TIMESTAMP.

SELECT CAST((TRUNC(SYSDATE)) AS TIMESTAMP); +---------------------+ | trunc | +---------------------+ | 2011-07-21 00:00:00 | +---------------------+

On this page

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.