Android Question Compare Date

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hello,
how can I check if a date is before or after, respect to another?
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hi,
yes it is correct, but in this code:

B4X:
Dim f As Boolean
Dim d, t As Long
DateTime.DateFormat = "dd/MM/yyyy"
d = DateTime.DateParse(aData)
t = DateTime.Add(DateTime.Now, 0, 0, 1)

If DateTime.Date(d) = DateTime.Date(t) Then
        f = False
    Else
        f = True
End If

The variable F is always False.
Why?
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
B4X:
Dim f As Boolean
Dim d, t As Long
DateTime.DateFormat = "dd/MM/yyyy"
d = DateTime.DateParse( "07/06/2015")
t = DateTime.Add(DateTime.Now, 0, 0, 1) 'this returns F=true because today is 5th
' t = DateTime.Add(DateTime.Now, 0, 0, 2) 'this returns F=false because today is 5th + 2 = 7th


Log(DateTime.Date(d) & " " & DateTime.Date(t))
If DateTime.Date(d) = DateTime.Date(t) Then
        f = False
    Else
        f = True
End If   

Log(f)
 
Upvote 0
Top