> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/action-center/compare/compare-with-day.md).

# Compare With Day

**Compare With Day** narrows the assets passed along a workflow to what changed. It runs the Condition node's saved query against the completed discovery from x days ago, then compares that old result with the current one. Depending on **direction**, it passes on the assets that are new in the current result (**Added**) or the assets that were in the old result but are gone now (**Removed**).

Use **Compare With Date** to compare with a fixed calendar date, or **Compare With Last Discovery** to compare with the previous discovery. See [Compare With Specific Date](broken://pages/89603324c683c082611efd148972693fce144710) and [Compare With Last Discovery](broken://pages/38b9579684e9d7950622a0e3f09f2146b2ab4143).

### Before you begin

* Connect the job directly after a **Condition node**. The job compares that condition's query. Without a condition on the previous node, the job is skipped and the log says "Compare job has been skipped. It must be connected to condition node."
* A completed discovery must exist for the target day. If none is found, the job is skipped with a warning and the assets pass on unchanged.
* The job accepts these asset types: device, user, application, vulnerability, certificate, service, source code, AI, domain and policy.
* Each asset is matched by a key column, which the job requires in the node's columns:

| Asset type                                                  | Key column       |
| ----------------------------------------------------------- | ---------------- |
| device                                                      | `Hostname`       |
| user, certificate, service, source code, AI, domain, policy | `PrimaryKey`     |
| application                                                 | `NameAndVersion` |
| vulnerability                                               | `Id`             |

* The job has no connection fields, so nothing is required in [Action Center Settings](broken://pages/2bc5a56c2dcb8ef89cc0d72d4c41b59f8d5561f1).

### Settings

| Setting      | Type    | Required | Default | Description                                                                                                                                                      |
| ------------ | ------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| direction    | Choice  | No       | `Added` | `Added` passes assets that are in the current result but not in the old one. `Removed` passes assets that were in the old result but are not in the current one. |
| compare\_day | Integer | No       | `1`     | How many days ago the discovery to compare with ended. `1` means yesterday.                                                                                      |

### How it works

1. The job finds the first completed, non-deleted discovery whose end time falls on the day `compare_day` days before today (in the server's current time zone).
2. For every selected asset type, it runs the Condition node's query text on that old discovery and collects the key values of the matches.
3. It compares those with the assets currently flowing in the workflow. It runs once per asset type, not once per asset.
4. It replaces the workflow's assets with the result and marks each one with a `compare_status` value:

| direction | Condition                                          | `compare_status`    |
| --------- | -------------------------------------------------- | ------------------- |
| Added     | The asset did not exist in the old discovery       | `new_machine`       |
| Added     | The asset existed but did not match the query then | `parameter_added`   |
| Removed   | The asset is not in the current discovery          | `removed_machine`   |
| Removed   | The asset still exists but no longer matches       | `parameter_removed` |

For **Removed**, the passed-on assets are the old records from the earlier discovery. The next job node receives only these assets. If nothing changed, it receives none for that asset type.

### Example

Notify when devices appear that match a condition and were not there yesterday.

| Node             | Value                                     |
| ---------------- | ----------------------------------------- |
| Condition        | Saved query: devices without antivirus    |
| Compare With Day | direction: `Added`, compare\_day: `1`     |
| Next job         | A notification job, for example Send Mail |

### What's next?

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Compare With Specific Date</strong></td><td>Compare with a fixed calendar date.</td><td><a href="broken://pages/89603324c683c082611efd148972693fce144710">Broken link</a></td></tr><tr><td><strong>Compare With Last Discovery</strong></td><td>Compare with the previous discovery and skip small changes.</td><td><a href="broken://pages/38b9579684e9d7950622a0e3f09f2146b2ab4143">Broken link</a></td></tr><tr><td><strong>About Action Center</strong></td><td>Workflows, triggers, conditions and job nodes.</td><td><a href="broken://pages/770677b93eb449b2e9819d4c13d63e600c9d490b">Broken link</a></td></tr></tbody></table>
