I want to compare two times in VB.net:
I have 1:42:21 PM and I want it to compare with TimeOfDay in VB.net how can I do that?
I want to compare two times in VB.net:
I have 1:42:21 PM and I want it to compare with TimeOfDay in VB.net how can I do that?
Or you can enclose a
DateTime
expression in#
signs:You'd work out the format of your input time, and then call the ToString() method on your vb.net object, putting the same format in.
So for example, if your input format is h:mm:ss tt as it appears to be in your case, one method would be to do:
If you want to do some kind of comparison, you should use the DateTime.Parse() function to convert your input date into a DateTime object. Then you can simply use the > or < signs:
is it something along the lines of this that you are looking for?
To compare the time portion of two DateTime values:
Show the time difference in hours, minutes and seconds