Compare Date between Current and given Date using C# and VB.Net

Last Reply one year ago By dharmendr

Posted one year ago

Hello All 

I Have date field into daabase into varchar and date save as varchar 


i want to compare between current date to this 

int result = DateTime.Compare(DateTime.Now.ToString(),05/31/2019);

but it showing error how to do this please give me advise 

Posted one year ago

Hi ps222,

Refer below code.


 int result = DateTime.Compare(DateTime.Now, Convert.ToDateTime("05/31/2019"));


Dim result As Integer = DateTime.Compare(DateTime.Now, Convert.ToDateTime("05/31/2019"))