how to check entered date should be greater than system date in vb.net
function, user-defined-functions, vb.net, windows, winforms
Solution
If you could pass the date as a `Date` type then it is simply as this:
Private Function expiryvalidate(ByVal myDate As Date) As Boolean
Return myDate < Today
End Function
http://msdn.microsoft.com/en-us/library/system.datetime.today%28v=vs.110%29.aspx
It will return true if the passed date as argument is less than the current system date, otherwise it will return false.
If you need to pass the date as string to the function then you can call it as this:
dim IsExpired as boolean = expiryvalidate(date.parse("mystringdate"))
Problem
heres the problem, i pass a date to function in the following format: mm/dd/yyyy. when i pass the date as 02/02/2010 to the function it always returns true but i have put the condition that if date is less than system date it should return false but still it returns true for dates entered less than system date.heres the function. ``` Private Function expiryvalidate(ByVal exp As String) As Boolean Dim ee As String ee = Format(CDate(exp), "MM/dd/yyyy") Dim dd As String = Format(DateTime.Now, "MM/dd/yyyy") If ee <> "0" Then If ee < dd Or ee = dd Then Return False Else Return True End If Else Return True End If End Function ```