Subtract Time Delta
How Long Ago? Subtract a Duration From a Date
- datetime
- delta
- DATETIME
The mirror image of Add Time Delta, doing what subtraction does: take a DATETIME, take a TIMEDELTA, and return the DATETIME that's that far back in the past. "A week ago," "90 minutes before that render," "yesterday at this exact time" - that's this node's whole job, and it handles the month/year rollover math so you don't have to.
How it works
From StableLlama's Basic data handling pack. Two required inputs, both custom types from this pack:
datetime- a DATETIME, typically fromTimeNow,TimeNowUTC, orTimeParse.delta- a TIMEDELTA fromCreate Time Delta.
Under the hood it's datetime - delta, so all the Python semantics you'd hope for apply: subtract 3 days from the 1st of the month and it rolls into the previous month correctly, and negative results aren't a thing to worry about. The output is a new DATETIME, which you then route wherever a DATETIME goes - TimeFormat for a string, TimeExtract for components, TimeToUnix for a Unix timestamp.
Where it fits
- "How long ago" windows - now minus
days=7gives you a week-ago anchor to compare or clean against. - Backdating filenames - generate yesterday's or last month's timestamp string for archive naming.
- Retry logic - "if this timestamp is older than X, do it again" is exactly a subtract-then-compare flow using
TimeDifference.
Notice the pattern across this pack: durations come out of Create Time Delta, points in time come out of the now/parse nodes, and this node (or TimeAddDelta) is what bridges the two. If you need to measure the gap between two dates rather than shift one, that's TimeDifference - a different node for a different question.
Installing it
Search "Basic data handling" in ComfyUI Manager and restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Restart and it's live. No dependencies, no models.
Gotchas
Same custom-type reminder as the add version: delta has to be a real TIMEDELTA built by Create Time Delta, not a number you typed in - a red wire here means you skipped that step. And since there's no sign field on the inputs, "go back in time" is always this node, never a negative delta in the add node, even though both technically work. Pick one pattern and keep your graphs consistent so you can read them later.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| datetime | DATETIME | — | |
| delta | TIMEDELTA | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| DATETIME | DATETIME | — |