I want to do basicly : When clicked on a button i want to save the date and when the app launched again 2 days later for exi. i want to get the date again and get the difference from last save. ( I can save the dates to a file , no problem with thar i just want to know how can i get the date and get the difference between 2 days )
Either use the DateUtils library or the code mode, not both:
B4X:
Dim MyDays As Int
DateTime.DateFormat="d/M/yyyy"
Dim PastDate As String="14/12/2013" 'Use your proper date format
MyDays=DateUtils.PeriodBetweenInDays(DateTime.DateParse(PastDate),DateTime.Now).Days
Msgbox(MyDays,"") 'displays 2
'DateTime.DateFormat="M/d/yyyy"
Note that only DateUtils.PeriodBetween or BetweenInDays are 100% correct. All the others solutions, including code that I posted, will work in 99% of the cases.