Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
CHRIS_Singa
Creator
Creator

Convert Hour to minutes

Hello

I would like to convert hours to minutes. 

How can I make this with qlik Sense (Back-end script) ? 

WORKING_HOUR.PNG

 

 

 

 

 

Can someone help with this issue please ?

Thank you in advance

1 Solution

Accepted Solutions
Chanty4u
MVP
MVP

You can modify above script 

LOAD 

    Ticket,

    Working_Hour,

    Floor(Working_Hour * 60) AS [Minutes], // Extract Whole Minutes

    Round((Working_Hour * 60 - Floor(Working_Hour * 60)) * 60) AS [Seconds], // Extract Remaining Seconds

    Floor(Working_Hour * 60) & ' minutes and ' & Round((Working_Hour * 60 - Floor(Working_Hour * 60)) * 60) & ' seconds' AS [Formatted Time]

INLINE [

    Ticket, Working_Hour

    1, 160.56

    2, 20.3

    3, 53.32

    4, 10.5

 

  5, 25.1

];

View solution in original post

6 Replies
nhenckel
Luminary
Luminary

 

You can calculate minutes by simply multiplying your hour field by 60 in the script. For example:

Working_Hour * 60 AS [Expected minutes]

Here’s a sample script showing how it works:

LOAD 
    Ticket,
    Working_Hour,
    Working_Hour * 60 AS [Expected minutes]
INLINE [
    Ticket, Working_Hour
    1, 160.56
    2, 20.3
    3, 53.32
    4, 10.5
    5, 25.1
];

This will give you the minutes based on your hour values.

nhenckel_0-1743180588157.png

CHRIS_Singa
Creator
Creator
Author

Thank you for the feedback. 

What can I do if iwant to view as : 9633 minutes and ..... secondes 

Do you have any suggestion ?

Chanty4u
MVP
MVP

You can modify above script 

LOAD 

    Ticket,

    Working_Hour,

    Floor(Working_Hour * 60) AS [Minutes], // Extract Whole Minutes

    Round((Working_Hour * 60 - Floor(Working_Hour * 60)) * 60) AS [Seconds], // Extract Remaining Seconds

    Floor(Working_Hour * 60) & ' minutes and ' & Round((Working_Hour * 60 - Floor(Working_Hour * 60)) * 60) & ' seconds' AS [Formatted Time]

INLINE [

    Ticket, Working_Hour

    1, 160.56

    2, 20.3

    3, 53.32

    4, 10.5

 

  5, 25.1

];

MarcoWedel

although this question already has a solution I just wanted to propose this one as well:

MarcoWedel_1-1749674295514.png

 

table1:
LOAD Ticket,
            WorkingHour,
            Dual(Replace(Interval(WorkingHour/24,'mm:ss'),':',' minutes and ')&' seconds',WorkingHour/24) as ExpectedMinutes
Inline [
Ticket, WorkingHour
1,160.56
2,20.3
3,53.32
4,10.5
5,25.1
];

 

CHRIS_Singa
Creator
Creator
Author

Thank you for the propose.

This is an easy way to deal with that case as well

MarcoWedel

glad you liked it