Im doing simple calculation with time, to see how long the process has been running.
(DateTime.Now - StrtTime).ToString("hh:mm:ss")
Where StrtTime is:DateTime StrtTime = DateTime.Now;
. But im getting an exception:
Input string was not in a correct format.
Whats the proper way to do this?
One
DateTimesubtracting another results in aTimeSpanvalue, not anotherDateTime. TheTimeSpandoes not support your given format string.For standard
TimeSpanformat strings, see here, and here for custom formats.However, to measure the process time, you should instead use a tool better equipped for the task,
System.Diagnostics.Stopwatch.