timeToDecimal

 public static Decimal timeToDecimal(this string time)
        {
            int Hours = time.Split(':')[0].ToInt();
            decimal Minutes = time.Split(':')[1].ToInt();
            while (Minutes >= 60)
            {
                Minutes = Minutes % 60;
                Hours ++;
            }
            //Minutes = Minutes/60;
            long test = Convert.ToInt64((Minutes/60)/10);
            return Hours + Minutes/60;
        }
Example:
Convert a time string in decimal format.
decimal time = "19:70".timeToDecimal();

Some examples: 
19:30 to 19.5 
19:70 to 20.166666666666666666666666667
12:45 to 12.75

Description

Convert string time(hh:mm) in decimal

Details

Double click on the code to select all.

 

;