Menu
Amazon QuickSight
User Guide

truncDate Function

truncDate returns a date value that represents a specified portion of a date. For example, requesting the year portion of the value 2012-09-02T00:00:00.000Z returns 2012-01-01T00:00:00.000Z. Specifying a time-related period for a date that doesn't contain time information returns the initial date value unchanged.

Syntax

Copy
truncDate('period', date)

Arguments

period

The period of the date that you want returned. Valid periods are as follows:

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

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

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

  • WK: This returns the week portion of the date.

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

date

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

Return Type

Date

Example

The following example returns a date representing the month of the order date.

Copy
truncDate('MM', {order date})

For the field values:

Copy
order date ========= 2012-12-14T00:00:00.000Z 2013-12-29T00:00:00.000Z 2012-11-15T00:00:00.000Z

The following values are returned:

Copy
2012-12-01T00:00:00.000Z 2013-12-01T00:00:00.000Z 2012-11-01T00:00:00.000Z