I have a duration dimension. I want it to show the number of days and hours. For example, if the difference between sql_start and sql_end is 60.4 hours, I want it to show 2 days, 12 hours. Instead it either shows 3 days or 60 hours.
It is important DATEDIFF(second, […])/60/60/24.00) as using DATEDIFF(day, […]) would only give you a whole number. Alternatively you could simplify it to DATEDIFF(second, […])/86400.00). The two decimal zeros ensure that the output will be a decimal number, too.
days_hours
Next, use the dimensions days as input for the days_hours dimension. Subparameter type has to be number. You then set the value_format subparameter to the output you would like to have following the guidelines for customizing a number format as defined by Microsoft.
In your case you wanted to show the number of days and the number of hours and two strings, remember to escape the quotes of the string using a backslash.
Good point! I think you’re right that all of the built in durations will round. I think you’d have to write a custom dimension to get a day-hour display.
Thanks. This is what I had. I was hoping to find something that still used the “duration” data type. It seems that Looker does not handle durations well, and I should just use numbers in general.