Home » Tableau » DATEPARSE in Tableau

DATEPARSE in Tableau

What is DATEPARSE function in Tableau

The DATEPARSE() function in Tableau is used to convert a string into a date or datetime value. It returns a date or datetime value based on the format string and input string provided. This is useful when you have a date or datetime value stored as a string in your data source, and you need to convert it to a date or datetime format that Tableau can understand.

Below is the syntax for using the DATEPARSE in Tableau:

DATEPARSE(parse_string, date_string)
  • parse_string: it specifies the format of the date or datetime string that you want to convert. This should be a string that includes special formatting codes that represent the different parts of the date or datetime. For example, “dd/MM/yyyy” specifies that the
  • date string: is in the format “day/month/year”. date_string is the string that you want to convert to a date or datetime format.

Also read: More Logical functions IIF Function and ZN Function

Below are the five examples to explain in details about the use of DATEPARSE function in Tableau, below example will helpful for you to understand in deep and details.

Example #1: Parse a date from a string in the format ‘MM/dd/yyyy’:

Lets take specific date example, in the below syntax we have string as date and DATEPARSE converting the sting into date format that is MM/DD/YYYY.

DATEPARSE('MM/dd/yyyy', '02/15/2022')

This returns the date value #2022-02-15#.

Example #2: Parse a datetime from a string in the format ‘MM/dd/yyyy hh:mm:ss’:

Lets take specific date example, in the below syntax we have string as date and DATEPARSE converting the sting into date format that is MM/DD/YYYY hh:mm:ss.

DATEPARSE('MM/dd/yyyy hh:mm:ss', '02/15/2022 10:30:00')

This returns the datetime value #2022-02-15 10:30:00#.

Example #3: Parse a date from a string in the format ‘dd-MMM-yy’:

Let’s take specific date example, in the below syntax we have string as date and DATEPARSE converting the sting into date format that is dd-MM-yyy.

DATEPARSE('dd-MMM-yy', '15-Feb-22')

This returns the date value #2022-02-15#.

Example #4: Parse a datetime from a string in the format ‘dd-MMM-yy hh:mm:ss’:

Let’s take specific date example, in the below syntax we have string as date and DATEPARSE converting the sting into date format that is dd-MM-yyy hh:mm:ss.

DATEPARSE('dd-MMM-yy hh:mm:ss', '15-Feb-22 10:30:00')

This returns the datetime value #2022-02-15 10:30:00#.

Example #5: Parse a date from a string in the format ‘yyyy-MM-dd’:

Let’s take specific date example, in the below syntax we have string as date and DATEPARSE converting the sting into date format that is yyyy-MM-dd.

DATEPARSE('yyyy-MM-dd', '2022-02-15')

This returns the date value #2022-02-15#.

In each example, the DATEPARSE() function converts a string into a date or datetime value based on the specified format string. The resulting value can be used in calculations or displayed in a visualization. It is important to ensure that the format string matches the input string to avoid errors in parsing.