Convert duration to decimal

zeonzeon Member Posts: 130
Hi,

Is there a way to convert a duration to a decimal value?

Duration like: "8 hours and 30 minutes" translates to 8,50.

I have two datetime fields and I want to know the hours an employee have worked represented in decimal. The employees work can span across midnight.

E.g:

Start 10-01-12 22:00:00
End 10-02-12 06:00:00

I want the value 8,00.

/zeon

Answers

  • MBergerMBerger Member Posts: 413
    Just substract them and put them in a decimal variable, you'll get the number of milliseconds. Divide by 3600000 ( 60 * 60 * 1000 ) and you'll get your value.
  • zeonzeon Member Posts: 130
    Thanks, just found that solution myself also :)

    Example:
    Start := CREATEDATETIME(TODAY-1,220000T);
    End := CREATEDATETIME(TODAY,053000T);
    Total := (End - Start)/1000/60/60;
    
Sign In or Register to comment.