Android Question Compare Date

imgsimonebiliato

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

imgsimonebiliato

Well-Known Member
Licensed 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?
 

eurojam

Well-Known Member
Licensed 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)
 

eurojam

Well-Known Member
Licensed User
I'm wrong, or your code is the same as I provided?
Yes, sure it is your code....I've played only with values, changed aData to "07/06/2015" and looked what will happen. I seems that all systems are up and working like they should....:)
 
Top