DatePart
Last updated
Was this helpful?
Last updated
Was this helpful?
The DatePart function extracts the specified date part from a date value.
Analytics Pro returns the result(s) in your organization's time zone. This may cause days, months, or years to appear offset, if the specified time zone is ahead of the organization's time zone. To view the output presented in the specified time zone, apply the ConvertTimeZone function.
DatePart(precision, date, [timezone])
The function has the following arguments:
precision
Required The date part extracted. Can be one of “year”, "quarter", “month”, “week”, “day”, "weekday", “hour”, “minute”, “second”, “millisecond”, or "epoch".
date
timezone
DatePart("year", [Invoice Date])
Extracts the year from each value in the column of invoice dates.
DatePart("week", Date("2007-01-10 10:00:00"))
Returns 2, the week number of this date; weeks in Analytics Pro start on Sunday, by default.
The DatePart function returns the following values for the Date column:
Required Date or column of dates where Analytics Pro extracts the date part. The value must be a date. If the column is not in the appropriate format, use the function on the argument.
Optional TZ identifier of the for the date part. For example, ”America/Los_Angeles”. If omitted, defaults to UTC.