Options

duration in hours format

shwetashweta Member Posts: 94
I have taken a variable say temp of duration where value are calculated as temp:=(to time-from time).to time and from time both are of time data type.If result is coming as 3 hrs 29 min 50 sec
then i want it to be displayed as 3.49 hrs
How i can do it
Please help me

Comments

  • Options
    Stardust77Stardust77 Member Posts: 95
    The time is displayed according to your setup done for Time in the Regional and Language Options from your Control Panel.
  • Options
    BBlueBBlue Member Posts: 90
    Hello,

    You can do this by using an int variable for subtracting time. If you have variables time1 and time2 of TIME type then the rezult of (time2 - time1) will be expressed in milliseconds. So, in order to achieve what you want - to express the rezult in hours - you have to divide the integer by 1000 * 60 * 60.
    Exemple:

    Name DataType Subtype Length
    Time1 Time
    Time2 Time
    Int Integer
    Time1 := 103020T;
    Time2 := 113000T;
    Int := Time2 - Time1;
    MESSAGE('%1',Int/3600000);
    

    I hope this will help you.
    //Bogdan
  • Options
    shwetashweta Member Posts: 94
    Thanks for the suggestion it is working fine
    BBlue wrote:
    Hello,

    You can do this by using an int variable for subtracting time. If you have variables time1 and time2 of TIME type then the rezult of (time2 - time1) will be expressed in milliseconds. So, in order to achieve what you want - to express the rezult in hours - you have to divide the integer by 1000 * 60 * 60.
    Exemple:

    Name DataType Subtype Length
    Time1 Time
    Time2 Time
    Int Integer
    Time1 := 103020T;
    Time2 := 113000T;
    Int := Time2 - Time1;
    MESSAGE('%1',Int/3600000);
    

    I hope this will help you.
  • Options
    BBlueBBlue Member Posts: 90
    You are welcome :)
    //Bogdan
Sign In or Register to comment.