Other day we saw how to extract numbers from a string lets spice the things up let’s see how we can extract Dates from a string.

At first we will see how extract a string in the Format of

MM/M(any character)DD/D(any Character)YYYY/YY OR
DD/D(any character)MM/M(any character)YYYY/YY

Sample Data

FormatText String
MM-DD-YYYYI born on 12-09-1994
MM.DD.YYYYI born on 12.09.1994
MM/DD/YYYYI born on 12/09/1994
M/D/YYYYI Born on 1/1/1994
M/D/YYI Born on 1/1/94
M-D/YYYYI Born on 1-9/1994
MM?DD?YYYYI Born on 12/09/1994
M-DD-YYI Born on 1-09/94
DD-MM-YYI Born on 09-12-1994

Calculation at Tableau Level

Pattern : (\d{1,2}.\d{1,2}.\d{2,4})

Final O/P:

Lets Extract the dates which are

Month Name(any Character)DD/D(any Character)YYYY/YY

MonthJanuary OR JAN or jan or january or JANUARY
Day9 OR 09
year2019 OR 19

Sample Data:

FormatText String
MMMM/DD/YYYYI Born on September/12/1994
MMM/DD/YYYYI born on Sep/12/1994
MMM/D/YYI Born on SEP/9/94

Tableau Calculation:



As if you see we used lower for the text string to match the pattern for lower case if you want you can use UPPER and change your Pattern to below


WEEKDAY :Lets try to extract Weekday from string

Sample Data:

Text Format
I born on September,12 2019 which is on Sunday

Tableau Calculation:



Time Extract: Either 24 Hr or AM/PM

Sample Data:

I Born on 10:12:12 AM
I born at 1:56:00 PM
I Born at 13:12:59 am

Tableau Calculation:

‘((?:(?:(?:0?[1-9]|1[0-2])(?::|.)[0-5]\d(?:(?::|.)[0-5]\d)? ?[aApP][mM])|(?:(?:0?\d|1\d|2[0-3])(?::|.)[0-5]\d(?:(?::|.)[0-5]\d)?)))’)



  1. rgxdb
  2. rgexr

Hope you enjoyed this blogspot. Do Subscribe by entering your email in the footer to get the new content