if(DateTime.Now>=OldDateTime)..????
-
how can i do something like If (DateTime.Now >= StoredDateTime) ??? i extract the StoredDateTime from database which is save in earlier time useing DateTime.Now.ToString(); I don't know the setting of time in the machine so i can't expect the returned format .... so how can i accomplish this task.. ADEL K Khalil
-
how can i do something like If (DateTime.Now >= StoredDateTime) ??? i extract the StoredDateTime from database which is save in earlier time useing DateTime.Now.ToString(); I don't know the setting of time in the machine so i can't expect the returned format .... so how can i accomplish this task.. ADEL K Khalil
Why are you converting the DateTime to a string. Why not keep it as instance of a DateTime object, you can then use the compare method. Also, use DateTime.UtcNow, instead of Now - this will ensure that your time is always stored using the same timezone. It's should be quite easy to convert it back to the user's timezone for display purposes. If your stuck saving it as a string to the database, then you should be able to use the string format objects to control the format it is saved as.
-
how can i do something like If (DateTime.Now >= StoredDateTime) ??? i extract the StoredDateTime from database which is save in earlier time useing DateTime.Now.ToString(); I don't know the setting of time in the machine so i can't expect the returned format .... so how can i accomplish this task.. ADEL K Khalil
Chris is right, try to make the structure in your database hold a DateTime object and not a string. If you try to query the database for dates using comparisons other than equals, you'll get unexpected results since it'll be returning rows based on the STRING value of the datetime, not the actual datetime. Good luck!