Visual Basic has this function called Datediff that shows number of days between 2 dates. I am looking for a similar function in B4A. I see that B4A has DateTime.Add but it sounds more like adding (or subtracting) days to a certain date to get the new date. I need the reverse. Is it possible?
Thank you, but that doesn't accept 2 days and show their difference. For example I have 25/11/2011 and 26/11/2011. I need a function to subtract 25/11/2011 from 26/11/2011 so that the answer is 1. In DateTime.Add, I can only subtract 1 from 26/11/2011 so that the answer is 25/11/2011. I need the opposite.
Ok, I understand. That also is not too difficult. You could use a function like this;
B4X:
Dim tks, d, h, m, s As Long
tks = DateTime.DateParse("06/15/2011") - DateTime.DateParse("06/05/2011")
d = tks / DateTime.TicksPerDay
ToastMessageShow(d, True)
The result will show you that the difference is 10 days.
Somehow I missed TicksPerDay when I checked out the documentation. I was wondering all along how to reverse a tick to readable date. Thanks for the help mate.