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

Last Reply 6 months ago By dharmendr

Posted 6 months 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 

You are viewing reply posted by: dharmendr 6 months ago.
Posted 6 months 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"))