How to find difference between two dates?

I am trying to find the number of days between two dates. Is there any way to find it in CROSS PLATFORM?

Hello, this is a snippet from a project I made to calculate the differences between two dates (although the second date is the current date, so you’ll just have to replace it). Please note this does not include year, my project did not need that. You can just check if the years are equal and if not add 365 (check if it is a leap year, though).

https://x.thunkable.com/copy/96c4399a014ae6500ed78af11ab8d968

Sorry this is not a complete answer, it’s just to give you a starting place and some ideas.

2 Likes

So I was looking for a non-API way of doing this, and I stumbled across Julian dates. Pretty nerdy, but there is an explanation here: https://stason.org/TULARC/society/calendars/2-15-1-Is-there-a-formula-for-calculating-the-Julian-day-nu.html and countless more explanations online, but I found this the simplest to put into blocks. Julian dates takes into account leap years and leap centuries, and this is a mathematically accepted way of finding the difference between two dates. In this example, the date picked FDOM is converted to a Julian date DOM. My variables L, M, S correspond to a, y, and m, respectively, in this link with the formula. To find the difference between two dates, subtract the Julian dates.

2 Likes

Sorry to bother you, I can’t access your link. What should I do?

This topic is over two years old so you may need to just copy the blocks in the screenshot above. Another option is to use a javascript to calculate what you need. I believe there are examples on the forum if you search.