Android Question Period elapsed between 2 datetime

rscheel

Well-Known Member
Licensed User
Longtime User
I have 2 dates with hours, I need to be able to calculate the period between one date and the other, I do not know how to do it, someone who can help me, the dates are string.

B4X:
Fecha1 = "2017-06-30 10:00:00"
Fecha2 = "2017-06-30 12:00:00"
 

eps

Expert
Licensed User
Longtime User
DateUtils is your friend : https://www.b4x.com/android/forum/threads/b4x-dateutils-simplifies-date-and-time-calcuations.26290/

e.g.

B4X:
'Calculates the period between two date instances.
'This method returns a Period type with years, months, days, hours, minutes, seconds.
Sub PeriodBetween(Start As Long, EndTime As Long) AsPeriod

'Calculates the period between two date instances.
'This method returns a Period type with days, hours, minutes, seconds
Sub PeriodBetweenInDays (Start As Long, EndTime As Long) AsPeriod
 
Upvote 0
Top