Date/Math Brain Teaser! (Tea Break Quickie)

Oli Mason's icon

Hi Guys,

Just a quick one,

I want to be able to work out quickly the number of days between 2 dates but struggling to get my head round a formula due to the different months having different lengths,

e.g "how many days between 16th Jan and 5th November,"

I haven't posted a patch beacuase the rest of it if just simple maths.

Any ideas/input always appreciated.

Regards,

Oli

Floating Point's icon

Use the subpatchers in this patch to achieve what you want. It comes from this thread:
https://cycling74.com/forums/what-do-you-do-when-number-is-too-big-to-process

Max Patch
Copy patch and select New From Clipboard in Max.

I needed to do the same thing as you a while back, and found a formulas for it somewhere on the internet...

Oli Mason's icon

An Answer in 11 mins! I love these forums!!

Thanks for taking the time to help Terry!

Regards,

Oli

Roman Thilenius's icon

i have never been doing this but i believe that the number of days per month/year is
known and one should be able to easily fit that all into one expr or if.

willyc's icon
Max Patch
Copy patch and select New From Clipboard in Max.

You could use javascript's Date class to the date calculations for you. The attached example could be 'cleaner' if done purely inside a js object. I've wrestled a solution via jstrigger object for easy forum-posting