---
schema_version: "1"
id: 4a73d593c7d4da0615376b917677da8439669f0cd813ad787e6363bd2f559fe4
title: Date Functions
collection: tableau
version: current
locale: en-gb
portal_url: https://docs.salesforce.com/tableau/current/en-gb/public/desktop/functions_functions_date.md
canonical_url: https://help.tableau.com/current/public/desktop/en-gb/functions_functions_date.htm
source_site: help.tableau.com
content_type: documentation
content_hash: 1ffada01ee249df66069810b76baab0b7c73fd41e84bb2cad6d138abb9d34ad9
description: Reference for Tableau date functions used in calculations.
---
[Skip to main content](#main-content)

# Date Functions

Dates are a common element in many data sources. If a field contains recognizable dates, it will have a **date** or **datetime** data type. When date fields are used in the viz they get a special set of functionality, including an automatic date hierarchy drill down, date-specific filter options and specialised date formatting options. Using dates in calculations often requires the use of date-specific functions.

## Gain familiarity with other date concepts

Date functions sometimes reference date-specific elements, including the `date_part` argument, the optional `[start_of_week]` parameter and date literals (#). These are covered in more detail at the end of this topic.

There are several other topics that might be of interest but aren't part of date functions:

- Format how a date is displayed in a viz: [Custom Date Formats](https://help.tableau.com/current/public/desktop/en-gb/dates_custom_date_formats.htm)
- Set default date properties: [Date Properties for a Data Source](https://help.tableau.com/current/public/desktop/en-gb/date_properties.htm)
- Work with fiscal dates: [Tax Dates](https://help.tableau.com/current/public/desktop/en-gb/dates_fiscal.htm)
- Use the ISO-8601 calendar: [ISO-8601 Week-Based Calendar](https://help.tableau.com/current/public/desktop/en-gb/dates_calendar.htm)

> [!TIP]
> 
>  Is your field already recognised as a date (it has a date icon in the Data pane) and you're trying to control how it appears in the viz? You might need to format it rather than use a date function. For example, you want to show 22Sept2024 as 09/24. This is handled through formatting the date, not a calculation.  
>   
> See [Custom Date Formats](https://help.tableau.com/current/public/desktop/en-gb/dates_custom_date_formats.htm) and related topics for working with date fields. The date functions on this page allow you to manipulate dates’ calculated fields, not set their display formatting.

## Date functions available in Tableau

### DATE

Type conversion function that changes string and number expressions into dates, as long as they are in a recognisable format.

<table class="table--plain"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>DATE(expression)</code></td></tr><tr><td>Output</td><td>Date</td></tr><tr><td>Definition</td><td>Returns a date given a number, string or date <code>&lt;expression&gt;</code>.</td></tr><tr><td>Example</td><td><pre>DATE([Employee Start Date])</pre><pre>DATE("September 22, 2018") </pre><pre xml:space="preserve">DATE("9/22/2018")</pre><pre>DATE(#2018-09-22 14:52#)</pre></td></tr><tr><td>Notes</td><td><p>Unlike <code><a href="#DATEPARS" class="xref">DATEPARSE</a></code>, there is no need to provide a pattern as <code>DATE</code> automatically recognises many standard date formats. If <code>DATE</code> does not recognise the input, however, try using <code>DATEPARSE</code> and specifying the format.</p><p><code><a href="#MAKEDATE" class="xref">MAKEDATE</a></code> is another similar function, but <code>MAKEDATE</code> requires the input of numeric values for year, month and day.</p></td></tr></tbody></table>

### DATEADD

Adds a specified number of date parts (months, days, etc) to the starting date.

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>DATEADD(date_part, interval, date)</code></td></tr><tr><td>Output</td><td>Date</td></tr><tr><td>Definition</td><td>Returns the <code>&lt;date&gt;</code> with the specified number <code>&lt;interval&gt;</code> added to the specified <code>&lt;<a href="#arg" class="xref">date_part</a>&gt;</code> of that date. For example, adding three months or 12 days to a starting date.</td></tr><tr><td>Example</td><td><p>Push out all due dates by one week</p><pre>DATEADD('week', 1, [due date])</pre><p>Add 280 days to the date February 20, 2021</p><pre xml:space="preserve">DATEADD('day', 280, #2/20/21#) = #November 27, 2021#</pre></td></tr><tr><td>Notes</td><td>Supports ISO 8601 dates.</td></tr></tbody></table>

### DATEDIFF

Returns the number of date parts (weeks, years, etc) between two dates.

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>DATEDIFF(date_part, date1, date2, [start_of_week])</code></td></tr><tr><td>Output</td><td>Integer</td></tr><tr><td>Definition</td><td>Returns the difference between <code>&lt;date1&gt;</code> and <code>&lt;date2&gt;</code> expressed in units of <code>&lt;<a href="#arg" class="xref">date_part</a>&gt;</code>. For example, subtracting the dates someone entered and left a band to see how long they were in the band.</td></tr><tr><td>Example</td><td><p>Number of days between 25th March 1986 and 20th February 2021</p><pre>DATEDIFF('day', #3/25/1986#, #2/20/2021#) = 12,751</pre><p>How many months someone was in a band</p><pre>DATEDIFF('month', [date joined band], [date left band])</pre></td></tr><tr><td>Notes</td><td>Supports ISO 8601 dates.</td></tr></tbody></table>

### DATENAME

Returns the name of the specified date part as a discrete string.

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>DATENAME(date_part, date, [start_of_week])</code></td></tr><tr><td>Output</td><td>String</td></tr><tr><td>Definition</td><td>Returns <code>&lt;<a href="#arg" class="xref">date_part</a>&gt;</code> of <code>&lt;date&gt;</code> as a string.</td></tr><tr><td>Example</td><td><pre>DATENAME('year', #3/25/1986#) = "1986"</pre><pre>DATENAME('month', #1986-03-25#) = "March"</pre></td></tr><tr><td>Notes</td><td><p>Supports ISO 8601 dates.</p><p>A very similar calculation is <a href="#DATEPART" class="xref">DATEPART</a>, which returns the value of the specified date part as a continuous integer. <code>DATEPART</code> can be faster because it is a numerical operation.</p><p>By changing the attributes of the calculation’s result (dimension or measure, continuous or discrete) and the date formatting, the results of <code>DATEPART</code> and <code>DATENAME</code> can be formatted to be identical.</p><p>An inverse function is <a href="#DATEPARS" class="xref">DATEPARSE</a>, which takes a string value and formats it as a date.</p></td></tr></tbody></table>

### DATEPARSE

Returns specifically formatted strings as dates.

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>DATEPARSE(date_format, date_string)</code></td></tr><tr><td>Output</td><td>Date</td></tr><tr><td>Definition</td><td>The <code>&lt;date_format&gt;</code> argument describes how the <code>&lt;date_string&gt;</code> field is arranged. Because of the variety of ways the string field can be ordered, the <code>&lt;date_format&gt;</code> must match exactly. For a full explanation and formatting details, see <a href="https://help.tableau.com/current/pro/desktop/en-gb/data_dateparse.htm" target="_blank">Convert a Field to a Date Field</a>.</td></tr><tr><td>Example</td><td><pre xml:space="preserve">DATEPARSE('yyyy-MM-dd', "1986-03-25") = #March 25, 1986#</pre></td></tr><tr><td>Notes</td><td><p><code><a href="#top" class="xref">DATE</a></code> is a similar function that automatically recognises many standard date formats. <code>DATEPARSE</code> may be a better option if <code>DATE</code> does not recognise the input pattern.</p><p><code><a href="#MAKEDATE" class="xref">MAKEDATE</a></code> is another similar function, but <code>MAKEDATE</code> requires the input of numeric values for year, month and day.</p><p>Inverse functions, which take dates apart and return the value of their parts, are <code><a href="#DATEPART" class="xref">DATEPART</a></code> (integer output) and <code><a href="#DATENAME" class="xref">DATENAME</a></code> (string output).</p></td></tr><tr><td>Database limitations</td><td><p><code>DATEPARSE</code> is available through the following connectors: non-legacy Excel and text file connections, Amazon EMR Hadoop Hive, Cloudera Hadoop, Google Sheets, Hortonworks Hadoop Hive, MapR Hadoop Hive, MySQL, Oracle, PostgreSQL and Tableau extracts. Some formats may not be available for all connections.</p><p><code>DATEPARSE</code> is not supported on Hive variants. Only Denodo, Drill and Snowflake are supported.</p></td></tr></tbody></table>

### DATEPART

Returns the name of the specified date part as an integer.

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>DATEPART(date_part, date, [start_of_week])</code></td></tr><tr><td>Output</td><td>Integer</td></tr><tr><td>Definition</td><td>Returns <code>&lt;<a href="#arg" class="xref">date_part</a>&gt;</code> of <code>&lt;date&gt;</code> as an integer.</td></tr><tr><td>Example</td><td><pre>DATEPART('year', #1986-03-25#) = 1986</pre><pre>DATEPART('month', #1986-03-25#) = 3</pre></td></tr><tr><td>Notes</td><td><p>Supports ISO 8601 dates.</p><p>A very similar calculation is <code><a href="#DATENAME" class="xref">DATENAME</a></code>, which returns the name of the specified date part as a discrete string. <code>DATEPART</code> can be faster because it is a numerical operation. By changing the attributes of the field (dimension or measure, continuous or discrete) and the date formatting, the results of <code>DATEPART</code> and <code>DATENAME</code> can be formatted to be identical.</p><p>An inverse function is <code><a href="#DATEPARS" class="xref">DATEPARSE</a></code>, which takes a string value and formats it as a date.</p></td></tr></tbody></table>

### DATETRUNC

This function can be thought of as date rounding. It takes a specific date and returns a version of that date at the desired specificity. Because every date must have a value for day, month, quarter and year, `DATETRUNC` sets the values as the lowest value for each date part up to the date part specified. Refer to the example for more information.

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>DATETRUNC(date_part, date, [start_of_week])</code></td></tr><tr><td>Output</td><td>Date</td></tr><tr><td>Definition</td><td>Truncates the <code>&lt;date&gt;</code> to the accuracy specified by the <code>&lt;<a href="#arg" class="xref">date_part</a>&gt;</code>. This function returns a new date. For example, when you truncate a date that is in the middle of the month at the month level, this function returns the first day of the month.</td></tr><tr><td>Example</td><td><pre xml:space="preserve">DATETRUNC('day', #9/22/2018#) = #9/22/2018#</pre><pre xml:space="preserve">DATETRUNC('iso-week', #9/22/2018#) = #9/17/2018#</pre><p>(the Monday of the week containing 22/09/2018)</p><pre xml:space="preserve">DATETRUNC(quarter, #9/22/2018#) = #7/1/2018# </pre><p>(the first day of the quarter containing 22/09/2018)</p><p class="note">Note: For week and iso-week, the <code>start_of_week</code> comes into play. ISO-weeks always start on Monday. For the locale of this example, an unspecified <code>start_of_week</code> means the week starts on Sunday.</p></td></tr><tr><td>Notes</td><td><p>Supports ISO 8601 dates.</p><p>You shouldn't use <code>DATETRUNC</code> to, for example, stop showing the time for a datetime field in a viz. If you want to truncate the way a date displays rather than round its accuracy, <a href="https://help.tableau.com/current/pro/desktop/en-gb/dates_custom_date_formats.htm" target="_blank">adjust the formatting</a>.</p><p>For example, <code>DATETRUNC('day', #5/17/2022 3:12:48 PM#)</code>, if formatted in the viz to display seconds, would display as <code>5/17/2022 12:00:00 AM</code>. The value is truncated to day, but the display goes to seconds.</p></td></tr></tbody></table>

### DAY

Returns the day of the month (1–31) as an integer.

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>DAY(date)</code></td></tr><tr><td>Output</td><td>Integer</td></tr><tr><td>Definition</td><td>Returns the day of the given <code>&lt;date&gt;</code> as an integer.</td></tr><tr><td>Example</td><td><pre>Day(#September 22, 2018#) = 22</pre></td></tr><tr><td>Notes</td><td>See also <code><a href="#WEEK" class="xref">WEEK</a></code>, <code><a href="#MONTH" class="xref">MONTH</a></code>, <code><a href="#QUARTER" class="xref">QUARTER</a></code>, <code><a href="#YEAR" class="xref">YEAR</a></code> and the ISO equivalents.</td></tr></tbody></table>

### ISDATE

Checks if the string is a valid date format.

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>ISDATE(string)</code></td></tr><tr><td>Output</td><td>Boolean</td></tr><tr><td>Definition</td><td>Returns true if a given <code>&lt;string&gt;</code> is a valid date.</td></tr><tr><td>Example</td><td><pre>ISDATE(09/22/2018) = true</pre><pre>ISDATE(22SEP18) = false</pre></td></tr><tr><td>Notes</td><td>The required argument must be a string. ISDATE cannot be used for a field with a date data type – the calculation will return an error.</td></tr></tbody></table>

### ISOQUARTER

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>ISOQUARTER(date)</code></td></tr><tr><td>Output</td><td>Integer</td></tr><tr><td>Definition</td><td>Returns the ISO8601 week-based quarter of a given <code>&lt;date&gt;</code> as an integer.</td></tr><tr><td>Example</td><td><pre>ISOQUARTER(#1986-03-25#) = 1</pre></td></tr><tr><td>Notes</td><td>See also <code><a href="#ISOWEEK" class="xref">ISOWEEK</a></code>, <code><a href="#ISOWEEKDAY" class="xref">ISOWEEKDAY</a></code>, <code><a href="#ISOYEAR" class="xref">ISOYEAR</a></code> and the non-ISO equivalents.</td></tr></tbody></table>

### ISOWEEK

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>ISOWEEK(date)</code></td></tr><tr><td>Output</td><td>Integer</td></tr><tr><td>Definition</td><td>Returns the ISO8601 week-based week of a given <code>&lt;date&gt;</code> as an integer.</td></tr><tr><td>Example</td><td><pre>ISOWEEK(#1986-03-25#) = 13</pre></td></tr><tr><td>Notes</td><td>See also <code><a href="#ISOWEEKDAY" class="xref">ISOWEEKDAY</a></code>, <code><a href="#ISOQUARTER" class="xref">ISOQUARTER</a></code>, <code><a href="#ISOYEAR" class="xref">ISOYEAR</a></code> and the non-ISO equivalents.</td></tr></tbody></table>

### ISOWEEKDAY

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>ISOWEEKDAY(date)</code></td></tr><tr><td>Output</td><td>Integer</td></tr><tr><td>Definition</td><td>Returns the ISO8601 week-based weekday of a given <code>&lt;date&gt;</code> as an integer.</td></tr><tr><td>Example</td><td><pre>ISOWEEKDAY(#1986-03-25#) = 2</pre></td></tr><tr><td>Notes</td><td>See also <code><a href="#ISOWEEK" class="xref">ISOWEEK</a></code>, <code><a href="#ISOQUARTER" class="xref">ISOQUARTER</a></code>, <code><a href="#ISOYEAR" class="xref">ISOYEAR</a></code> and the non-ISO equivalents.</td></tr></tbody></table>

### ISOYEAR

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>ISOYEAR(date)</code></td></tr><tr><td>Output</td><td>Integer</td></tr><tr><td>Definition</td><td>Returns the ISO8601 week-based year of a given <code>&lt;date&gt;</code> as an integer.</td></tr><tr><td>Example</td><td><pre>ISOYEAR(#1986-03-25#) = 1,986</pre></td></tr><tr><td>Notes</td><td>See also <code><a href="#ISOWEEK" class="xref">ISOWEEK</a></code>, <code><a href="#ISOWEEKDAY" class="xref">ISOWEEKDAY</a></code>, <code><a href="#ISOQUARTER" class="xref">ISOQUARTER</a></code> and the non-ISO equivalents.</td></tr></tbody></table>

### MAKEDATE

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>MAKEDATE(year, month, day)</code></td></tr><tr><td>Output</td><td>Date</td></tr><tr><td>Definition</td><td>Returns a date value constructed from the specified <code>&lt;year&gt;</code>, <code>&lt;month&gt;</code> and <code>&lt;day&gt;</code>.</td></tr><tr><td>Example</td><td><pre xml:space="preserve">MAKEDATE(1986,3,25) = #1986-03-25#</pre></td></tr><tr><td>Notes</td><td><p class="note"><b>Note</b>: Incorrectly entered values will be adjusted into a date, such as <code>MAKEDATE(2020,4,31) = May 1, 2020</code> rather than returning an error that there is no 31st day of April.</p><p>Available for Tableau Data Extracts. Check for availability in other data sources.</p><p><code>MAKEDATE</code> requires numerical inputs for the parts of a date. If your data is a string that should be a date, try the <code><a href="#top" class="xref">DATE</a></code> function. <code>DATE</code> automatically recognises many standard date formats. If <code>DATE</code> does not recognise the input, try using <code><a href="#DATEPARS" class="xref">DATEPARSE</a></code>.</p></td></tr></tbody></table>

### MAKEDATETIME

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>MAKEDATETIME(date, time)</code></td></tr><tr><td>Output</td><td>Datetime</td></tr><tr><td>Definition</td><td>Returns a datetime that combines a <code>&lt;date&gt;</code> and a <code>&lt;time&gt;</code>. The date can be a date, datetime or a string type. The time must be a datetime.</td></tr><tr><td>Example</td><td><pre>MAKEDATETIME("1899-12-30", #07:59:00#) = #12/30/1899 7:59:00 AM#</pre><pre>MAKEDATETIME([Date], [Time]) = #1/1/2001 6:00:00 AM#</pre></td></tr><tr><td>Notes</td><td><p>This function is available only for MySQL-compatible connections (which for Tableau are MySQL and Amazon Aurora).</p><p><code><a href="#MAKETIME" class="xref">MAKETIME</a></code> is a similar function available for Tableau Data Extracts and some other data sources.</p></td></tr></tbody></table>

### MAKETIME

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>MAKETIME(hour, minute, second)</code></td></tr><tr><td>Output</td><td>Datetime</td></tr><tr><td>Definition</td><td>Returns a date value constructed from the specified <code>&lt;hour&gt;</code>, <code>&lt;minute&gt;</code> and <code>&lt;second&gt;</code>.</td></tr><tr><td>Example</td><td><pre>MAKETIME(14, 52, 40) = #1/1/1899 14:52:40#</pre></td></tr><tr><td>Notes</td><td><p>Because Tableau does not support a time data type, only datetime, the output is a datetime. The date portion of the field will be 1/1/1899.</p><p>Similar function to <code><a href="#MAKEDATETIME" class="xref">MAKEDATETIME</a></code>, which is only available for MYSQL-compatible connections.</p></td></tr></tbody></table>

### MAX

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>MAX(expression)</code> or <code>MAX(expr1, expr2)</code></td></tr><tr><td>Output</td><td>Same data type as the argument, or <code>NULL</code> if any part of the argument is null.</td></tr><tr><td>Definition</td><td><p>Returns the maximum of the two arguments, which must be of the same data type.</p><p><code>MAX</code> can also be applied to a single field as an aggregation.</p></td></tr><tr><td>Example</td><td><pre xml:space="preserve">MAX(4,7) = 7<br>MAX(#3/25/1986#, #2/20/2021#) = #2/20/2021# <br>MAX([Name]) = "Zander"</pre></td></tr><tr><td>Notes</td><td><p><b>For strings</b></p><p><code>MAX</code> is usually the value that comes last in alphabetical order.</p><p class="note">For database data sources, the <code>MAX</code> string value is highest in the sort sequence defined by the database for that column.</p><p><b>For dates</b></p><p>For dates, the <code>MAX</code> is the most recent date. If <code>MAX</code> is an aggregation, the result will not have a date hierarchy. If <code>MAX</code> is a comparison, the result will retain the date hierarchy.</p><p><b>As an aggregation</b></p><p><code>MAX(expression)</code> is an aggregate function and returns a single aggregated result. This displays as <code>AGG(expression)</code> in the viz.</p><p><b>As a comparison</b></p><p><code>MAX(expr1, expr2)</code> compares the two values and returns a row-level value.</p><p>See also <code><a href="#MIN" class="xref">MIN</a></code>.</p></td></tr></tbody></table>

### MIN

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>MIN(expression)</code> or <code>MIN(expr1, expr2)</code></td></tr><tr><td>Output</td><td>Same data type as the argument, or <code>NULL&nbsp;</code>if any part of the argument is null.</td></tr><tr><td>Definition</td><td><p>Returns the minimum of the two arguments, which must be of the same data type.</p><p><code>MIN </code>can also be applied to a single field as an aggregation.</p></td></tr><tr><td>Example</td><td><pre xml:space="preserve">MIN(4,7) = 4<br>MIN(#3/25/1986#, #2/20/2021#) = #3/25/1986#<br>MIN([Name]) = "Abebi"</pre></td></tr><tr><td>Notes</td><td><p><b>For strings</b></p><p><code>MIN</code> is usually the value that comes first in alphabetical order.</p><p class="note">For database data sources, the <code>MIN</code> string value is lowest in the sort sequence defined by the database for that column.</p><p><b>For dates</b></p><p>For dates, the <code>MIN</code> is the earliest date. If <code>MIN</code> is an aggregation, the result will not have a date hierarchy. If <code>MIN</code> is a comparison, the result will retain the date hierarchy.</p><p><b>As an aggregation</b></p><p><code>MIN(expression)</code> is an aggregate function and returns a single aggregated result. This displays as <code>AGG(expression)</code> in the viz.</p><p><b>As a comparison</b></p><p><code>MIN(expr1, expr2)</code> compares the two values and returns a row-level value.</p><p>See also <code><a href="#MAX" class="xref">MAX</a></code>.</p></td></tr></tbody></table>

### MONTH

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>MONTH(date)</code></td></tr><tr><td>Output</td><td>Integer</td></tr><tr><td>Definition</td><td>Returns the month of the given <code>&lt;date&gt;</code> as an integer.</td></tr><tr><td>Example</td><td><pre>MONTH(#1986-03-25#) = 3</pre></td></tr><tr><td>Notes</td><td>See also <code><a href="#DAY" class="xref">DAY</a></code>, <code><a href="#WEEK" class="xref">WEEK</a></code>, <code><a href="#QUARTER" class="xref">QUARTER</a></code>, <code><a href="#YEAR" class="xref">YEAR</a></code> and the ISO equivalents</td></tr></tbody></table>

### NOW

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>NOW()</code></td></tr><tr><td>Output</td><td>Datetime</td></tr><tr><td>Definition</td><td>Returns the current local system date and time.</td></tr><tr><td>Example</td><td><pre>NOW() = 1986-03-25 1:08:21 PM</pre></td></tr><tr><td>Notes</td><td><p><code>NOW</code> does not take an argument.</p><p>See also <code><a href="#TODAY" class="xref">TODAY</a></code>, a similar calculation that returns a date instead of a datetime.</p><p>If the data source is a live connection, the system date and time could be in another time zone. For more information on how to address this, see <a href="https://kb.tableau.com/articles/issue/now-function-returns-utc-time?lang=en-gb">the Knowledge Base</a>.</p></td></tr></tbody></table>

### QUARTER

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>QUARTER(date)</code></td></tr><tr><td>Output</td><td>Integer</td></tr><tr><td>Definition</td><td>Returns the quarter of the given <code>&lt;date&gt;</code> as an integer.</td></tr><tr><td>Example</td><td><pre>QUARTER(#1986-03-25#) = 1</pre></td></tr><tr><td>Notes</td><td>See also <code><a href="#DAY" class="xref">DAY</a></code>, <code><a href="#WEEK" class="xref">WEEK</a></code>, <code><a href="#MONTH" class="xref">MONTH</a></code>, <code><a href="#YEAR" class="xref">YEAR</a></code> and the ISO equivalents</td></tr></tbody></table>

### TODAY

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>TODAY()</code></td></tr><tr><td>Output</td><td>Date</td></tr><tr><td>Definition</td><td>Returns the current local system date.</td></tr><tr><td>Example</td><td><pre>TODAY() = 1986-03-25</pre></td></tr><tr><td>Notes</td><td><p><code>TODAY</code> does not take an argument.</p><p>See also <a href="#NOW" class="xref">NOW</a>, a similar calculation that returns a datetime instead of a date.</p><p>If the data source is a live connection, the system date could be in another time zone. For more information on how to address this, see <a href="https://kb.tableau.com/articles/issue/now-function-returns-utc-time?lang=en-gb">the Knowledge Base</a>.</p></td></tr></tbody></table>

### WEEK

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>WEEK(date)</code></td></tr><tr><td>Output</td><td>Integer</td></tr><tr><td>Definition</td><td>Returns the week of the given <code>&lt;date&gt;</code> as an integer.</td></tr><tr><td>Example</td><td><pre>WEEK(#1986-03-25#) = 13</pre></td></tr><tr><td>Notes</td><td>See also <code><a href="#DAY" class="xref">DAY</a></code>, <code><a href="#MONTH" class="xref">MONTH</a></code>, <code><a href="#QUARTER" class="xref">QUARTER</a></code>, <code><a href="#YEAR" class="xref">YEAR</a></code> and the ISO equivalents</td></tr></tbody></table>

### YEAR

<table class="table--plain" style="width: 100%;"><colgroup><col style="width: 20%;"><col></colgroup><tbody><tr><td>Syntax</td><td><code>YEAR(date)</code></td></tr><tr><td>Output</td><td>Integer</td></tr><tr><td>Definition</td><td>Returns the year of the given <code>&lt;date&gt;</code> as an integer.</td></tr><tr><td>Example</td><td><pre xml:space="preserve">YEAR(#1986-03-25#) = 1,986</pre></td></tr><tr><td>Notes</td><td>See also <code><a href="#DAY" class="xref">DAY</a></code>, <code><a href="#WEEK" class="xref">WEEK</a></code>, <code><a href="#MONTH" class="xref">MONTH</a></code>, <code><a href="#QUARTER" class="xref">QUARTER</a></code> and the ISO equivalents</td></tr></tbody></table>

## date\_part

Many date functions in Tableau take the argument `date_part`, which is a string constant that tells the function what part of a date to consider, such as day, week, quarter, etc. The valid `date_part` values that you can use are:

| date\_part | Values |
| --- | --- |
| `'year'` | Four-digit year |
| `'quarter'` | 1-4 |
| `'month'` | 1-12 or "January", "February" and so on |
| `'dayofyear'` | Day of the year; 1st Jan 1, 1st Feb is 32 and so on |
| `'day'` | 1-31 |
| `'weekday'` | 1-7 or "Sunday", "Monday" and so on |
| `'week'` | 1-52 |
| `'hour'` | 0-23 |
| `'minute'` | 0-59 |
| `'second'` | 0-60 |
| `'iso-year'` | Four-digit ISO 8601 year |
| `'iso-quarter'` | 1-4 |
| `'iso-week'` | 1-52, start of week is always Monday |
| `'iso-weekday'` | 1-7, start of week is always Monday |

## The `[start_of_week]` parameter

Some functions have the optional parameter `[start_of_week]`. The `start_of_week` parameter can be used to specify what day is considered the first day of the week, such as "Sunday" or "Monday". If it is omitted, the start of week is determined by the data source. See [Date Properties for a Data Source](https://help.tableau.com/current/public/desktop/en-gb/date_properties.htm).

For the examples below, 22 September is a Sunday and 24 September is a Tuesday. The DATEDIFF function is being used to calculate the weeks between these dates.

`DATEDIFF('week', #2013-09-22#, #2013-09-24#, 'monday') = 1`

- Because start\_of\_week is 'monday', these dates are in different weeks.

`DATEDIFF('week', #2013-09-22#, #2013-09-24#, 'sunday') = 0`

- Because start\_of\_week is 'sunday', these dates are in the same week.

## The date literal (#)

Examples often use the pound symbol (#) with date expressions. This is the date literal, similar to using quotes for text strings, and it tells Tableau that the value inside the symbols is a date.

Without the date literals, dates may be interpreted as various other data types. For example:

<table style="width: 100%;"><colgroup><col><col><col></colgroup><tbody><tr><td style="font-weight: bold;">Format</td><td style="font-weight: bold;">Data Type</td><td style="font-weight: bold;">Value</td></tr><tr><td>'March 25, 1986'</td><td>String</td><td>'March 25, 1986'</td></tr><tr><td>#3/25/1986#</td><td>Date</td><td>#3/25/1986#</td></tr><tr><td>25/03/1986</td><td>Floating decimal</td><td>0.00006042</td></tr><tr><td>25/03/1986</td><td>Integer</td><td>1,958</td></tr><tr><td>March 25, 1986</td><td>-</td><td>invalid</td></tr></tbody></table>

![Data pane with various date format icons highlighted.](/tableau/current/en-gb/public/desktop/en-gb/Img/datefunc_dateformats.png)

For more information, see [Literal expression syntax](https://help.tableau.com/current/public/desktop/en-gb/functions_operators.htm#literals)

## Create a date calculation

Practice creating a date calculation using the Superstore sample data source.

1. In Tableau Desktop, connect to the **Sample-Superstore** saved data source, which comes with Tableau.
2. Open a worksheet.
3. From the **Data** pane, under Dimensions, drag Order Date to the Rows shelf.
4. On the **Rows** shelf, click the plus icon (**+**) on the **YEAR(Order Date)** field.
    
    QUARTER(Order Date) is added to the Rows shelf and the view updates.
    
    ![A table that displays order data by year and quarter.](/tableau/current/en-gb/public/desktop/en-gb/Img/datefunctions2.png)
5. On the Rows shelf, click the plus icon (**+**) on the QUARTER(Order Date) field to drill down to MONTH(Order Date).
    
    ![A table that shows the year, quarter and month of order dates.](/tableau/current/en-gb/public/desktop/en-gb/Img/datefunctions3.png)
6. Select Analysis \> Create Calculated Field.
7. In the calculation editor that opens, do the following:

- Name the calculated field, Quarter Date.
- Enter the following formula: `DATETRUNC('quarter', [Order Date])`
- When finished, click **OK**.
    
    The new date calculated field appears under **Dimensions** in the **Data** pane. Just like your other fields, you can use it in one or more visualisations.

9. From the **Data** pane, under Dimensions, drag Quarter Date to the Rows shelf and place it to the right of MONTH(Order Date). The visualisation updates with year values. This is because Tableau rolls date data up to the highest level of detail.
10. On the Rows shelf, right-click YEAR(Quarter Date) and select Exact Date.
11. On the Rows shelf, right-click YEAR(Quarter Date) again and select Discrete.
    
    The visualisation updates with the exact quarter date for each row in the table.
    
    ![A table that displays order dates by year, quarter, month and quarter date.](/tableau/current/en-gb/public/desktop/en-gb/Img/datefunctions1.png)