datetime Problem

thewavemaster

Member
Licensed User
Longtime User
following Code:

dim date1 as string
dim date2 as string
tim tks as long
dim dif as long

date1 = EditText1.Text
date2 = "02/01/2012" ' format is dd/MM/yyyy
tks = DateTime.DateParse(date1) - DateTime.DateParse(Date2)
dif= tks / DateTime.TicksPerDay

Why is for date1 = "25/03/2012" and date1 = "26/03/2012" the result dif = 83?

In the emulator it shows the right result...but on the mobilphone its the wrong (tested it on three different phones)
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've tried this code and it prints 83 and 84.
What does it print on your device?

B4X:
Sub Activity_Create(FirstTime As Boolean)
DateTime.DateFormat = "dd/MM/yyyy"
Dim date1 As String
Dim date2 As String
Dim tks As Long
Dim dif As Long
date1 = "25/03/2012"
date2 = "02/01/2012" ' format is dd/MM/yyyy
tks = DateTime.DateParse(date1) - DateTime.DateParse(date2)
dif= tks / DateTime.TicksPerDay
Log(dif)

date1 = "26/03/2012"
date2 = "02/01/2012" ' format is dd/MM/yyyy
tks = DateTime.DateParse(date1) - DateTime.DateParse(date2)
dif= tks / DateTime.TicksPerDay
Log(dif)


End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…