I am calculating totaltime of the employee for each day.I want weekly totaltime working hours.I am using for loop to calculate totaltime for 1 week.But i am storing Total time in String.How to add totaltime for week.
If i use DateTime i am getting date also but i want only time.
TotalTime - 9:00 for 1 day.
I should use Static variable to keep the Previous TotalTime in varible so that i can add previous and current day totaltime.
This is my code
Expand|Select|Wrap|Line Numbers
- for (int i = 3; i < count; i++)
- {
- string[] TimeSplit = SpliData(strData);
- //TimeIn.Add(Convert.ToDateTime(TimeSplit[0]));
- //TimeOut.Add(Convert.ToDateTime(TimeSplit[1]))
- string TimeValue = TimeSplit.ToString();
- string frmtimestring = TimeSplit[0];
- string toTimeString = TimeSplit[1];
- int frmTime = Convert.ToInt32(frmtimestring.Replace(":", ""));
- int totime = Convert.ToInt32(toTimeString.Replace(":", ""));
- if (frmTime > totime)
- {
- totime = totime + 2400;
- }
- string TotalTime = Convert.ToString(frmTime - totime).Replace("-", "");
- TotalTime = TotalTime.Substring(0, TotalTime.Length - 2) + ":" +TotalTime.Substring(TotalTime.Length - 2);
- }