Tableau Datepart

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.

Similar Articles

Comments

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

Featured

Most Popular

Super Mario Bros Wii – Mushroom Houses

I was wondering how to get all the matches in on the mushroom houses in Super Mario Bros Wii. Sure enough there are patterns...

Zipcode to City, State Excel Spreadsheet

I just decided to do this. I've been meaning to learn more about the vlookup function in Excel. I figured this one would be...

Community Service Letter Template

I’ve been asked on occasion by parents if their child can volunteer some hours in the non-profit organization I help out at. I guess...