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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Ramachandran MPosted Dec 17, 2019, 9:01 AM
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);
Amit MohantyPosted Dec 17, 2019, 1:04 AM