Problem with passing date to IF node to compare dates

Describe the problem/error/question

I am getting dates (in my case in seconds) and want to use it as a rule in the IF node to compare this date with the current date

What is the error message (if any)?


It seems that the Date & Time rule requires a type of Date but n8n provides only String

Please share your workflow

{
“nodes”: [
{
“parameters”: {},
“type”: “n8n-nodes-base.manualTrigger”,
“typeVersion”: 1,
“position”: [
0,
0
],
“id”: “10b1cbaa-a6c8-49e4-81c1-e84e197b21e3”,
“name”: “When clicking ‘Test workflow’”
},
{
“parameters”: {
“operation”: “search”,
“subreddit”: “smallbusiness”,
“keyword”: “looking for a solution”,
“limit”: 10,
“additionalFields”: {
“sort”: “hot”
}
},
“type”: “n8n-nodes-base.reddit”,
“typeVersion”: 1,
“position”: [
220,
0
],
“id”: “3a72ae03-1059-4aba-8ef9-60e9833026e1”,
“name”: “Reddit”,
“credentials”: {
“redditOAuth2Api”: {
“id”: “5XSMHWMXzAeNGU9E”,
“name”: “Reddit account”
}
}
},
{
“parameters”: {
“conditions”: {
“options”: {
“caseSensitive”: true,
“leftValue”: “”,
“typeValidation”: “strict”,
“version”: 2
},
“conditions”: [
{
“id”: “1b3b0724-3f56-45d1-a02a-26213469121d”,
“leftValue”: “={{ $json.ups }}”,
“rightValue”: 2,
“operator”: {
“type”: “number”,
“operation”: “gt”
}
},
{
“id”: “04b8663f-df03-44dc-985a-3e4f6a3f9e22”,
“leftValue”: “={{ $json.selftext }}”,
“rightValue”: “”,
“operator”: {
“type”: “string”,
“operation”: “notEmpty”,
“singleValue”: true
}
},
{
“id”: “fd9d2c48-1f04-442b-a320-bb5d3c74d881”,
“leftValue”: “={{ DateTime.fromSeconds($json.created).toISO() }}”,
“rightValue”: “”,
“operator”: {
“type”: “dateTime”,
“operation”: “afterOrEquals”
}
}
],
“combinator”: “and”
},
“options”: {}
},
“type”: “n8n-nodes-base.if”,
“typeVersion”: 2.2,
“position”: [
420,
0
],
“id”: “45e805f3-cfb0-49bd-953f-1246a5296743”,
“name”: “If”
}
],
“connections”: {
“When clicking ‘Test workflow’”: {
“main”: [
[
{
“node”: “Reddit”,
“type”: “main”,
“index”: 0
}
]
]
},
“Reddit”: {
“main”: [
[
{
“node”: “If”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “79a77c65395341caf2dc425c59f08c775489ad1be2e0de03ea9045c9a2cd127a”
}
}

Information on your n8n setup

  • n8n version: 1.79.3
  • Database (default: SQLite): N/A
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: MacOS

Hey @Dariusz_Mozgowoj try to not use toIso() as it converts to a string and creating the error.

{{ DateTime.fromSeconds($json.created) }}

It is still not Date but string, I have tried this. I manage to do this around using middle step of other node. However I believe it is highly inconvenient that this node is working now different now.

Can you post your workflow with some example data in a code block so that it will be properly rendered?

type or paste code here

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.