How to get the current date and time in Tableau?

A developer can get the current date and time in Tableau using the NOW() function.

Create a date calculation

Follow along with the steps below to learn how to create a date calculation.

  1. In Tableau Desktop, connect to the Sample-Superstore saved data source, which comes with Tableau.
  2. Navigate to 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.
  5. On the Rows shelf, click the plus icon (+) on the QUARTER(Order Date) field to drill down to MONTH(Order Date).
  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 visualizations.
  1. From the Data pane, under Dimensions, drag Quarter Date to the Rows shelf and place it to the right of MONTH(Order Date). The visualization updates with year values. This is because Tableau rolls date data up to the highest level of detail.
  2. On the Rows shelf, right-click YEAR(Quarter Date) and select Exact Date.
  3. On the Rows shelf, right-click YEAR(Quarter Date) again and select Discrete.The visualization updates with the exact quarter date for each row in the table.

Why use date functions

Date functions allow you to manipulate dates in your data source.

For example, you might have a date field with year, month, and day for each value (2004-04-15). From these existing values, you can create new date values with a date function, such as the DATETRUNC function. For example, you can find the date of the beginning of the quarter for any existing date value.

The date calculation might look something like this:

DATETRUNC('quarter', [Order Date])

So, if the original date is ‘3/27/2011’, using the above calculation would return ‘1/1/2011’ to indicate that Q1 started on January 1. If the original date is ‘5/3/2011’, then the calculation would return ‘4/1/2011’ to indicate that Q2 started on April 1, four months into the year.