Reputation: 687
Hello guys I have a MySQL database with some DATETIME
values stored. I want to compare those values in C# with the DateTime.Now
attribute. I just want to write:
if (DateTime.Now.ToString() < MySQL fetched DATETIME + 3 hours)
Thanks for all your tips
Upvotes: 0
Views: 459
Reputation: 98740
Do not compare your DateTime values with their string representations. You should compare them exactly as their values.
Instead;
MySqlDataReader
or any other structure to get the values from your database.GetDateTime(int)
method to get relevant Datetime value.And compare them like
if(DateTime.Now < fetchedDateTime.AddHours(3))
By the way, you should be aware of the case against DateTime.Now
.
Upvotes: 2