Thanks for your response.None is working for me. when I’m trying to extract date and convert into datetime/date, along with date I’m getting time as well like 10/20/2022 00:00:00 where i need only 10/20/2022
Yeah that’s the difference between a Date and a DateTime
If they both parse with the time being zero - then subtracting them would return the same as if the time portion wasn’t there, right?
Anyway if that bothers you, you could parse it to Date instead of DateTime and use DateDiff as in:
Dim date2Entered As String = InputBox("Enter a date")
Try
Dim date2 As Date = Date.Parse(date2Entered)
Dim date1 As Date = Now
' Determine the number of days between the two dates.
Dim days As Long = DateDiff(DateInterval.Day, date1, date2)
' This statement has a string interval argument, and
' is equivalent to the above statement.
'Dim days As Long = DateDiff("d", date1, date2)
MessageBox.Show("Days from today: " & days.ToString)
Catch ex As Exception
MessageBox.Show("Invalid Date: " & ex.Message)
End Try
DateValue(“10/20/2022”)-DateValue(“11/10/2022”)
i am getting the value as -21 as shown in the screenshot below you can then extract it out from there by splitting it based on : and getting the first value. Let me know if it works out