Stuck on Date Math!

I’m working on improving a shortcut I use to input my work schedule into my iOS calendar. No problems there… However as I started adding functionality to also have the Shortcut add relevant tasks associated with those days I started to run into the same issue. As long as the task occurs on that day (Which is a variable DATE), I’m fine. But I have several tasks that need to occur the night before.

I can’t find a way to instruct Shortcuts to take the date I’ve selected (Variable DATE) and go back 1 day. I can do this by using Taskpaper and plugging that into OF but I run into some other strangeness. I’d like to keep this to just basic Task Entry if possible.

Is there any way to create something similar to Taskpaper’s function of @due(DATE - 1d)?

I have a similar shortcut where I alter a time. What I do is Format [DateVariable], Copy [Content] to clipboard, then run JS to modify the date in Scriptable, Get clipboard, then use the new date/time in an action.

Your Scriptable script looks something like this (hopefully; I’m not able to test right now):

var paste = Pasteboard.paste();
var newDate = new Date(paste);
newDate.setDate(newDate.getDate()-1);
Pasteboard.copy(formatDate(newDate, “whatever date format you need goes here”));

Perhaps there’s a way to do it only using Shortcuts, though. It’d run faster than cutting over to Scriptable. And maybe there’s a better way to pass than using the clipboard.

Shortcuts has a build in action for doing this - maybe it’s called „adjust date“ or something along the line (in german it’s „Datum anpassen“) which allows you to either add or subtract periods from a given date. Would this be something like you are looking for?

2 Likes

Found it! And, yes, that’s exactly what I needed. It crashed my OF app on my iPad Pro and I had to reinstall after trying it but it seems to be working fine now. Weird but not it seems to be working fine! Thanks