date from elapsed days

mharter's icon

Hi folks!

For the last week I have been working on solving the problem of deriving a date MM DD YYYY from another date plus an arbitrary number of days. I tried various algorithms and then switched to look up tables. I could never reliably handle dates in leap years after February 28th without creating an overly complex patch that had timing problems. The included patch is designed to convert elapsed days since January first 2010.

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

I am giving up on my efforts using Max as a platform to solve this, but I'd love to know if anyone else had wrestled with this type of thing. Thanks!
MH

Floating Point's icon

There's actually formulas to work out what you want-- they're in the subpatchers I posted in
this thread:
https://cycling74.com/forums/what-do-you-do-when-number-is-too-big-to-process

It converts the date to an absolute number which you can add to or subtract from, then convert back to the date format.
T

mharter's icon

Thanks for the link Terry. I had been over that thread before, but I was unaware that your subpatches could be useful for what I am doing. I had tried to convert some formulas for date calculation to an [expr], but I could not think it through. It looks like you know your math!

My project requires that there be a weekly schedule, starting on the first Monday of the year, so finding the weekdays will be important. I will use mod 7 to do that. Otherwise I don't see any hurdles.

I spent the day today diving into Javascript and had some success finding relative dates using it. I would rather stay in Max though.

Thanks!
MH

Floating Point's icon

No worries -- glad it's of use. I've used that little subpatch (the formula I got off the internet somewhere--don't remember where now) a number of times to help out in scheduling in installations etc. Keep it handy!
T