ISSUE :
 
Profile photo
Submitted by Ramesh Shrestha
on May 22nd, 2011 at 08:39:01 EST

help with dateTime conversion

I am creating a small tool where user will enter the date and if the date is current date, I have to do certain function.

Can anyone help with the code to check if the date entered is current date?


Profile photo
Replied by Ramesh Shrestha
on May 22nd, 2011 at 08:39:16 EST
By the way, I am using VB.NET

Profile photo
Replied by Dave Smith
on May 22nd, 2011 at 11:42:04 EST
You can first use Date.Parse to convert your string date input to Date object and then compare with Date.Now.

Code snippet:
Public Function CheckCurrentDate(ByVal dateTime As String) As Boolean

Dim dateTime1 As Date
dateTime1 = Date.Parse(dateTime)

If (dateTime1 = Date.Now.Date) Then
Return True
Else
Return False
End If

End Function
Accepted Answer
Accepted
 Answer

Profile photo
Replied by Ramesh Shrestha
on May 22nd, 2011 at 12:01:32 EST
thanks. have a nice day.