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

Extract

Focus mode
Extract - Amazon QuickSight

extract returns a specified portion of a date value. Requesting a time-related portion of a date that doesn't contain time information returns 0.

Syntax

extract(period, date)

Arguments

period

The period that you want extracted from the date value. Valid periods are as follows:

  • YYYY: This returns the year portion of the date.

  • Q: This returns the quarter that the date belongs to (1–4).

  • MM: This returns the month portion of the date.

  • DD: This returns the day portion of the date.

  • WD: This returns the day of the week as an integer, with Sunday as 1.

  • HH: This returns the hour portion of the date.

  • MI: This returns the minute portion of the date.

  • SS: This returns the second portion of the date.

  • MS: This returns the millisecond portion of the date.

    Note

    Extracting milliseconds is not supported in Presto databases below version 0.216.

date

A date field or a call to another function that outputs a date.

Return type

Integer

Example

The following example extracts the day from a date value.

extract('DD', orderDate)

The following are the given field values.

orderDate ========= 01/01/14 09/13/16

For these field values, the following values are returned.

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