check if date is between two dates??

ilan

Expert
Licensed User
Longtime User
hi

i have a startdate and a enddate


for example

startdate = 1/8/2013
enddate = 31/8/2013

now i would like to know if a third date is between of the two dates
how is it possible i have try it like this but its not working

B4X:
If nowdate1 >= startdate AND nowdate1 <= enddate Then
'.....
End if
 

Mahares

Expert
Licensed User
Longtime User
You need to parse the dates first before you can compare them:

B4X:
DateTime.DateFormat = "d/M/yyyy"
Dim MyDate As String="20/8/2013"
Dim D As Long= DateTime.DateParse(MyDate)
Dim DS As Long= DateTime.DateParse("1/8/2013")
Dim DE As Long= DateTime.DateParse("31/8/2013")
If D >= DS AND D <= DE Then
  Msgbox(MyDate & " is between","")
Else
  Msgbox(MyDate & " is not between","")
End If
 
Upvote 0
Top