B4J Question Check days between two dates

Colin Evans

Active Member
Licensed User
Longtime User
Hi, probably very simple but I can't get my head round it

I have an SQL database where the date is held in the format 2020-09-24, I need to check what the difference is between the dates, so the start date may be 2020-09-24 next date may be 2020-09-22, next one could be 2020-08-23 etc so I need to record the number of days between the start date and the other dates
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
DateTime.DateFormat = "MM/dd/yyyy"
Dim PerDiff As Period = DateUtils.PeriodBetween( DateTime.Dateparse("10/11/1960"), DateTime.Now)
 
Upvote 0

Colin Evans

Active Member
Licensed User
Longtime User
Thanks, DonManfred. that's along the lines I wanted, don't suppose there's any way just to get the difference in just days, I could just add the number of days in the month to the number of days if month equals a figure, thanks again but that would be dependant of parsing the perdiff variable
 
Upvote 0

Colin Evans

Active Member
Licensed User
Longtime User
Cheers all, I found it DateUtils.PeriodBetweenindays, very useful tool, appreciate your input and guidance
 
Upvote 0
Top