> For the complete documentation index, see [llms.txt](https://docs.augelab.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.augelab.com/function-blocks/blocks-reference/data-logic/data-operations/datetime-compare.md).

# Datetime Compare

This function block compares a given datetime against a reference datetime. The reference can be built from individual date/time parts or defaults to the current system date/time when parts are left empty. The result is a simple boolean check that you can use to control other parts of your scenario.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

* `Input Date` (input)
  * Provide a full datetime string in the format YYYY-MM-DD HH:MM:SS to be compared.
* `Year` (input)
  * Optional. Provide a year (YYYY). Leave empty to use the current year.
* `Month` (input)
  * Optional. Provide a month (MM). Leave empty to use the current month.
* `Date` (input)
  * Optional. Provide a day of month (DD). Leave empty to use the current day.
* `Hour` (input)
  * Optional. Provide hour (HH). Leave empty to use current hour.
* `Minute` (input)
  * Optional. Provide minute (MM). Leave empty to use current minute.
* `Second` (input)
  * Optional. Provide second (SS). Leave empty to use current second.

## 📤 Outputs <a href="#outputs" id="outputs"></a>

* `Boolean` (output)
  * Returns TRUE or FALSE based on the selected relation between the provided `Input Date` and the assembled reference datetime.

## 🕹️ Controls <a href="#controls" id="controls"></a>

* `Relation` - Dropdown with comparison options: `==`, `~=`, `<`, `<=`, `>=`, `>`
  * Choose how the two datetimes will be compared (equal, not equal, less, less or equal, greater or equal, greater).

## 🎯 Features <a href="#features" id="features"></a>

* Easy comparison between a full datetime and a constructed reference datetime.
* Reference datetime parts default to the current system date/time when left empty.
* Simple boolean output suitable for logic flows, triggering actions, or logging.

## ⚙️ Running mechanism <a href="#running-mechanism" id="running-mechanism"></a>

* The block accepts a full datetime as `Input Date` and builds a reference datetime from the individual part inputs (`Year`, `Month`, `Date`, `Hour`, `Minute`, `Second`).
* Any part left empty uses the current system value for that part.
* The block compares the two datetimes using the selected `Relation` control and emits a boolean result.

## 📝 Usage instructions <a href="#usage" id="usage"></a>

1. Provide a full datetime string to `Input Date` in the format YYYY-MM-DD HH:MM:SS.
2. Optionally fill any of `Year`, `Month`, `Date`, `Hour`, `Minute`, `Second` to form a custom reference. Leave fields empty to use the current system values for those parts.
3. Select the comparison operator in the `Relation` dropdown.
4. Use the boolean output to drive logic, triggers, or logging blocks.

## 💡 Tips and Tricks <a href="#tips-and-tricks" id="tips-and-tricks"></a>

* Combine with `Date-Time` to easily obtain the current datetime string and feed it into `Input Date` for quick checks.
* Use `Date-Time List` when you want to supply each datetime part from a prebuilt list rather than individual inputs.
* Use `String Input` to let an operator type a custom datetime at runtime.
* Connect the boolean output to `Logic Input` or other logic blocks (for example `And`, `Or`) to build time-based control flows.
* Log matches or events by connecting the result to `CSV Export` or `Image Logger` for audit trails.
* Use `Debug Input` to inspect intermediate values while building your scenario.

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

* If comparisons behave unexpectedly, ensure `Input Date` matches the required format YYYY-MM-DD HH:MM:SS.
* If a part input is empty, the block uses the current system value for that part—verify that this is intended.
* If you need only a date-level comparison (ignore time), set time parts to zeros or ensure both sides use consistent precision.
