简体   繁体   中英

Hour conversion in Tableau

I have a data-set that has time (hours) data in it.

The time data is given as 0.1123 , 3.1565 , 0.2951 etc (all in hours).

How do I convert it into standard hours and minute format?

We can achieve this using two methods

1.Change to Date & Time

Once the data has been imported in Tableau. Change the data type of the column to "Date & Time" . Tableau data engine automatically understand the time format and change the decimal time to Actual time Refer this Image

2. Using Calculated Field "MAKETIME"

MAKETIME Requires three argument(hour, minute, second).Below code parse decimal number "3.1545" as 3 hrs, 9 min (0.15*60) and 16 sec (0.0045*3600)

MAKETIME(INT([DecimalTime]), int(INT(([DecimalTime] 100)%100) .6), int(INT(([DecimalTime] 10000)%100) .36))

Floor([value]) = the number of hours

Floor([value] * 60) % 60 = the number of minutes

Floor([value] * 3600) % 3600 = the number of seconds

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM