How to calculate days between two dates

how to calculate days between two dates?

edit: current system time - 13.12.2019

Convert dates to miliseconds.
Then Date 2 minus Date 1.
Then convert miliseconds to 24hours.

Or something like that :sweat_smile:


how to convert to miliseconds ? current system date

Use this block:

blocks (57)

From this extension:

com.LukeGackle.countdown.aix (11.2 KB)


the clock component offers methods for calculation with date and time, for example the DurationtoDays method…
see also Sensor Components - App Inventor for Android

Duration Duration(InstantInTime start, InstantInTime end)
Returns duration, which is milliseconds elapsed between instants

number DurationToDays(Duration duration)
Converts the duration to the number of days.

there is no need to use an extension…



Use this:

This would be the number of days elapsed since the beginning of the year.
If you have two specific dates, you can turn them both into instants and use them as start and stop for a duration (which is expressed in milliseconds) that can then be converted to days.
(CalibrateClock is just how I call one of the clock I use in one of my app; you have complete freedom how you can call your components)


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.