BeforeRelativeDate
Checks the given datetime has occured before the provided relative time.
python · Filters And Transformers
Details
| ID | BeforeRelativeDate |
|---|---|
| Language | python |
| From Version | 5.0.0 |
| Docker Image | demisto/python3:3.12.13.10404775 |
| Tags | date filter Condition |
README
Checks the given datetime has occurred before the provided relative time.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | date, filter, Condition |
| Cortex XSOAR Version | 5.0.0 |
Inputs
| Argument Name | Description |
|---|---|
| left | Date value to check - Can be any time format. ex. “2020-01-01T00:00:00” |
| right | Relative time ex. “6 months ago” |
Outputs
The script returns a boolean value (true or false) indicating if the date is before the relative time.
import pytest import demistomock as demisto from BeforeRelativeDate import check_date, main TEST_INPUTS = [ ("2025-09-12T12:00:00", "1 day ago", True, "Before date - No TZ"), ("2025-09-12T12:00:00", "19 years ago", False, "Not before date - No TZ"), ("1999-09-12T12:00:00z", "19 years ago", True, "Before date - Zulu"), ("2100-09-12T12:00:00", "19 years ago", False, "Not before - No TZ"), ] @pytest.mark.parametrize("left, right, expected_result, test_title", TEST_INPUTS) def test_check_date(left, right, expected_result, test_title): assert check_date(left, right) == expected_result, test_title def test_results(mocker): import BeforeRelativeDate mocker.patch.object(demisto, "args", return_value={"left": "2025-09-12T12:00:00", "right": "1 day ago"}) mocker.patch("BeforeRelativeDate.check_date", return_value=True) mocker.patch.object(BeforeRelativeDate, "return_results") main() call = BeforeRelativeDate.return_results.call_args_list command_results = call[0].args[0] assert command_results.outputs def test_error_results(mocker): import BeforeRelativeDate mocker.patch.object(demisto, "args", return_value={"value": "", "right": "1 day ago"}) mocker.patch("BeforeRelativeDate.check_date", return_value=True) mocker.patch.object(BeforeRelativeDate, "return_error") main() call = BeforeRelativeDate.return_error.call_args_list command_results = call[0] assert "Error Occured" in command_results.kwargs["message"] assert "A required input is missing or malformed." in command_results.kwargs["error"]