I have input data like example need to convert as decimal
Ex : 24:30:02 output as 24.5
Thank you.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amit MohantyRank #112 · 20K reputationPosted Dec 16, 2019, 8:04 PM EST
Ramachandran MRank #2,660 · 522 reputationPosted Dec 17, 2019, 4:01 AM EST
string[] a = HoursWorkedThisWeek.Split(new string[] { ":" }, StringSplitOptions.None);
//a[0] contains the hours, a[1] contains the minutes
decimal decHours = Math.Round(Convert.ToDecimal(a[0]) + (Convert.ToDecimal(a[1]) / 60), 2);