Wrong approach. Don't manipulate strings representing data, manipulate data. Don't compare strings, don't compare integers representing time, compare the objects of
System.DateTime
type. Try to avoid using strings, but if some data comes from strings, parse it first, and then compare.
Please see all the methods named
Parse
,
ParseExact
,
TryParse
and
TryParseExact
:
http://msdn.microsoft.com/en-us/library/system.datetime%28v=vs.110%29.aspx[
^].
For comparison, use the operators defined for this type: '==', '>=', '<=', '<', '>', '-'.
—SA