Convert a time to a number

I have a user that has his own dataset and I am converting it so that it is all done through an ETL but the issue is that he has a Average Handling time of 06:32 but he wants to see it as 6.32.

I am have had to convert the times to decimal to work and then covert it back to time doing the following:
SEC_TO_TIME(
FLOOR(Decimal AHT) * 3600 +
FLOOR((Decimal AHT - FLOOR(Decimal AHT)) * 60) * 60 +
ROUND(((Decimal AHT - FLOOR(Decimal AHT)) * 60 - FLOOR((Decimal AHT - FLOOR(Decimal AHT)) * 60)) * 60)
)
and this gives me Time to AHT which is 06:32:37

But now when when I try to convert the time to his format I get 6.00 and I am using this formula:
POWER( SEC_TO_TIME(
FLOOR(Decimal AHT) * 3600 +
FLOOR((Decimal AHT - FLOOR(Decimal AHT)) * 60) * 60 +
ROUND(((Decimal AHT - FLOOR(Decimal AHT)) * 60 - FLOOR((Decimal AHT - FLOOR(Decimal AHT)) * 60)) * 60)
),1)

I have tried to use the 1*with that formula but I now get a blank.
I need to get a number because he is using a Horizontal graph to look at all of his agents.

Any suggestions are appreciated.

Thank you

Best Answers

  • JBerr
    JBerr Member
    Answer ✓

    Ok I think I made it work using Power() and having that crazy formula in there because it converted my text to a number that is actually visible.

  • Manasi_Panov
    Manasi_Panov Contributor
    Answer ✓

    Hello @JBerr,

    Maybe I didn't understand your question, but isn't it possible to just use a simple REPLACE function like this:

    CAST(REPLACE(Time 1, ':', '.') AS FLOAT)

    If you found this post helpful, please use 💡/💖/👍/😊 below! If it solved your problem, don't forget to accept the answer.

  • JBerr
    JBerr Member
    Answer ✓

    Hi Mansal,

    That also worked!

Answers

  • You can try and use the FORMAT function to format your Date field to a string in the format you want:

    FORMAT(`date`, '%H.%s')
    

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • JBerr
    JBerr Member

    Hi Grant,

    I tried it and kind of worked but its now a text and now trying to convert that to a number and I'll fail.

  • JBerr
    JBerr Member
    Answer ✓

    Ok I think I made it work using Power() and having that crazy formula in there because it converted my text to a number that is actually visible.

  • Manasi_Panov
    Manasi_Panov Contributor
    Answer ✓

    Hello @JBerr,

    Maybe I didn't understand your question, but isn't it possible to just use a simple REPLACE function like this:

    CAST(REPLACE(Time 1, ':', '.') AS FLOAT)

    If you found this post helpful, please use 💡/💖/👍/😊 below! If it solved your problem, don't forget to accept the answer.

  • JBerr
    JBerr Member
    Answer ✓

    Hi Mansal,

    That also worked!