Convert Integer to hours

ricky76ricky76 Member Posts: 204
Hi, I wondered if anyone could help me. I want to convert an integer value to hours and minutes but am not sure how to do it. For example i have the integer value 200 and i want to show this as 3:20:00. Any help would be most appreciated.

Comments

  • SogSog Member Posts: 1,023
    standard you've got the evaluate function.
    But if you've got some transformation of your own in mind you should write a function.
    200 trough evaluate with a time variable shows 20:00:00
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • SpawnSpawn Member Posts: 10
    Hi,
    My suggestion is simple. Use variable of type Duration (represent the difference between two datetimes, in milliseconds.) to calculate time.

    Example:
    // 03:20 = (3 * 60 minutes) + 20 minutes = 200 minutes
    // 200 minutes = 200 * 60 seconds = 12 000 seconds
    // 12 000 seconds = 12 000 * 1000 milliseconds = 12 000 000 milliseconds
    
    varInteger := (3 * 60 + 20) * 60 * 1000; // desired time specified in milliseconds.
    varDuration := var varInteger;
    varTime := 0000T + varDuration;
    
    MESSAGE(FORMAT(varTime)); // result is 03:20:00
    
    So simply add some duration period in milliseconds to zero time and calculating a new time.
    Hope it help.
  • ricky76ricky76 Member Posts: 204
    Thank you for your help. I did manage to get this sorted using something similar to what Spawn wrote. Many thanks.
Sign In or Register to comment.