Android Code Snippet [B4X] Number of weeks between 2 dates

B4X:
Public Sub NumberOfWeeksBetween(StartDate As Long,EndDate As Long) As Int
    Return Round(DateUtils.PeriodBetweenInDays(StartDate,EndDate).Days / 7)
End Sub
 
Last edited:

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Is this really right. Your example says that no matter what day of week the start/end days are on that just any 7 days is a week????
 

Alexander Stolte

Expert
Licensed User
Longtime User
apparently your week has more or less than 7 days, but I can only speak for myself and for the people I know, for whom 1 week always goes exactly 7 days.
Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday = 7 days.
 

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Is a start date starting on Sunday and end date of Monday a week
or starting on Saturday and ending on Sunday.

Isn't a week a full Sunday to Saturday or Monday to Sunday - Do you consider particles days of a week a full week?
 
Top