Android Question Date comparison

Anser

Well-Known Member
Licensed User
Longtime User
Hi,

Can anybody confirm that whether anything wrong in the below given code. It just compare that whether the given date is lesser than the Current date.

B4X:
DateTime.DateFormat = "yyyy-MM-dd"
Dim cSelectedDate As String = "2016-06-22"
Dim dSelectedDate As Long = DateTime.DateParse(cSelectedDate)

ToastMessageShow(cSelectedDate,False) 'This toastmessage is displayed. Beyond this point nothing happens

If dSelectedDate < DateTime.Date(DateTime.Now) Then 'Compare with current date
    ToastMessageShow("Date is lesser than the current date",False)
    Return
Else
    ToastMessageShow("Date is greater than Current date",False)        
End If
ToastMessageShow("Date check completed",False)

What am I doing wrong. My app does not show any messages. It will show only the first ToasMessage, the second or third is not shown

Regards

Anser
 

DonManfred

Expert
Licensed User
Longtime User
you are comparing a string with a long

try

B4X:
If dSelectedDate < DateTime.Now
 
Upvote 0
Top