Android Question Day differences

tufanv

Expert
Licensed User
Longtime User
Hello,

I looked for some codes regarding to get days difference between 2 dates. But they were a bit complicated ( http://www.b4x.com/android/forum/threads/get-difference-days-from-today-faster-way.31117/)

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 )

TY
 

Mahares

Expert
Licensed User
Longtime User
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"
 
Upvote 0
Top