66.9 F
San Francisco
Wednesday, July 28, 2021

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.

Edel Alonhttp://edelalon.com
Edel-Ryan Alon is a starving musician, failed artist, connoisseur of fine foods, aspiring entrepreneur, husband, father of two, geek by day, cook by night, and an all around great guy.

Related Articles

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.

Stay Connected

440FollowersFollow
9,970FollowersFollow
17SubscribersSubscribe
- Advertisement -spot_img

Latest Articles