Android Question TicksPerDay in dates substracting

advansis

Active Member
Licensed User
Longtime User
Hi guys, I was writing a function similar to DATEDIFF (VB6/VB.NET) and just wanted to get the number of days between two dates.
I did not understand why two consecutive days (D1 and D2 in this code) differ less than then the value of DateTime.TicksPerDay
I can use the ceil() function, but cannot understand this behaviour...

B4X:
DateTime.DateFormat="yyyyMMdd"
Dim D1 As Long=DateTime.DateParse("20240331")
Dim D2 As Long=DateTime.DateParse("20240401")
Dim D0 As Long=DateTime.DateParse("20000101")

Log ("Diff 1-0: " & ((D1-D0)/DateTime.TicksPerDay)) ' returns 8856
Log ("Diff 2-0: " & ((D2-D0)/DateTime.TicksPerDay)) ' returns 8856.95833...
Log ("Diff 2-1: " & ((D2-D1)/DateTime.TicksPerDay)) ' returns 0.95833...

Thanks
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…