Reputation: 6938
I want to compare two dates in C# i have tried Toshortdate() but its not working for me i dont know why? I just want to compare the dates not the time.. My code is as below:
Convert.ToDateTime(b.CreatedDate).ToShortDateString() == Convert.ToDateTime(objbreedable.LastBDate).ToShortDateString()
Please help me.
Upvotes: 1
Views: 12803
Reputation: 3077
Use Date property.
Convert.ToDateTime(b.CreatedDate).Date == Convert.ToDateTime(objbreedable.LastBDate).Date
Upvotes: 3