How to calculate the difference between dates

I need to know the number of days between today and the date of birth

1 Like

You can use a clock. You can get the duration with the duration() block. The start will be the birth date, and the end will be the now() block. The images are down below.
component_method (1)
component_method
Also, the birth date will have to be in date picker format.

2 Likes

Buy the number is seconds?

Okay, first of all, tell me the format of the date of birth. Will it be from a date picker?


The result was 165920643 to day 2020/06/28

the difference between today and yesterday should have been 1 day but it was 165920643

Sorry, I told you to use the wrong blocks. Sorry. You should check out the post below. It is pretty easy. I am so sorry for all this mess.

1 Like

The duration is returned in milliseconds

1 Like

grafik

1 Like

See this Gallery app to do it all in blocks ...
http://ai2.appinventor.mit.edu/?galleryId=6104963528523776

1 Like

You can also use the Clock's DurationToDays method:

blocks (65)

3 Likes

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