Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am getting the value from datetime coloumn from database.Which is like as 6/2/2011 4:12:55 PM.
Then from using ToShortTimeString() on this i will get like 4:12:55 PM.
Then how i am compare the two time values which are like (4:12:55 PM)..??
Posted

1 solution

Rule 1: never convert to string if you want to do any manipulation on dates or times.

Instead, if you use the DateTime.TimeOfDay property[^] then it returns a TimeSpan which is effectively the time since midnight. You can compare two of these directly.
 
Share this answer
 
Comments
Espen Harlinn 6-Feb-11 6:34am    
Good answer, 5+
Richard MacCutchan 6-Feb-11 7:43am    
It's actually quite scary how many people seem to be commercial programmers, and yet do not understand such basics of computing.
OriginalGriff 6-Feb-11 7:55am    
It is if they ever start coding nuclear power stations! :laugh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900