Last post Jul 23, 2017 12:41 PM by PatriceSc
Jul 23, 2017 10:59 AM|libra_ali786|LINK
I am trying to minus to time but getting the error "Cannot convert from system.dateTime to system.TimeSpan"
In my last line OT varibale have a issue, My prime objective is to calculate overtime if total hour greate then 8.
DateTime OT = new System.DateTime(1, 1, 1, 8, 0, 0);
TimeSpan daytotalhours = ((time2 - time) + (time4 - time3));
TimeSpan dayOThours = daytotalhours.Subtract(OT);
Jul 23, 2017 12:41 PM|PatriceSc|LINK
You are trying to subtract a datetime from a duration which doesn't make sense. My understanding is that you want rather to define OT as a duration? Maybe :
TimeSpan OT = new System.TimeSpan(8, 0, 0);