I had a funky import into Tableau from Excel where my time entry where 1:23 turned into December 31, 1898 0:01:23 AM. For my data, I needed the number of minutes and seconds and was hoping that 1:23 would read as 1 minute and 23 seconds to then convert it to 83 seconds. In order to convert the MM DD, YYYY HH:MM:SS to something I can use, I had to use the DATEPART function in Tableau. This function looks like:
DATEPART(date_part, date)
To do so, I created a calculated field to pulled out the number of seconds and wrote the function as:
DATEPART(“minute”,[field name])*60+DATEPART(“second”,[field name])
I did have to calculate the total number of minutes by doing this:
DATEPART(“minute”,[field name])+DATEPART(“second”,[field name])/60
Doing this changed the result to 1.38333333333.
Returns date_part
of date
as an integer.
Thanks for reading. Send me a note if you want to see more Tableau stuff.