1.
Firstly, to compare the difference between then and now,
You need to subtract the past date from the current date. Currently you are doing this the opposite way, and you are not using the built-in minus operator.
2.
If you want to compare the number of days between the two dates,
Then you need to divide the result by 86400 (seconds in a day).
You can use the floor function to reduce it further to whole days.
3.
Lastly, you do not need formatNumber
since both results in a numeric output.
You also do not need parseDate
on the {{now}} variable, since it’s already a Date type variable.
Output
Module Export
You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.
-
Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block
-
Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.
-
Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.
Click to Expand Module Export Code
JSON - Copy and Paste this directly in the scenario editor
{
"subflows": [
{
"flow": [
{
"id": 10,
"module": "util:SetVariables",
"version": 1,
"parameters": {},
"mapper": {
"variables": [
{
"name": "xfrDate",
"value": "{{formatDate(parseDate(\"3/1/2024\"); \" X\")}}"
},
{
"name": "Current",
"value": "{{formatDate(now; \"X\")}}"
}
],
"scope": "roundtrip"
},
"metadata": {
"designer": {
"x": 300,
"y": 150
},
"restore": {
"expect": {
"variables": {
"items": [
null,
null
]
},
"scope": {
"label": "One cycle"
}
}
},
"expect": [
{
"name": "variables",
"type": "array",
"label": "Variables",
"spec": [
{
"name": "name",
"label": "Variable name",
"type": "text",
"required": true
},
{
"name": "value",
"label": "Variable value",
"type": "any"
}
]
},
{
"name": "scope",
"type": "select",
"label": "Variable lifetime",
"required": true,
"validate": {
"enum": [
"roundtrip",
"execution"
]
}
}
],
"interface": [
{
"name": "xfrDate",
"label": "xfrDate",
"type": "any"
},
{
"name": "Current",
"label": "Current",
"type": "any"
}
]
}
},
{
"id": 11,
"module": "util:SetVariables",
"version": 1,
"parameters": {},
"mapper": {
"variables": [
{
"name": "SecondsDiff",
"value": "{{10.Current - 10.xfrDate}}"
},
{
"name": "DaysDiff",
"value": "{{floor((10.Current - 10.xfrDate) / 86400)}}"
}
],
"scope": "roundtrip"
},
"metadata": {
"designer": {
"x": 600,
"y": 150
},
"restore": {
"expect": {
"variables": {
"items": [
null,
null
]
},
"scope": {
"label": "One cycle"
}
}
},
"expect": [
{
"name": "variables",
"type": "array",
"label": "Variables",
"spec": [
{
"name": "name",
"label": "Variable name",
"type": "text",
"required": true
},
{
"name": "value",
"label": "Variable value",
"type": "any"
}
]
},
{
"name": "scope",
"type": "select",
"label": "Variable lifetime",
"required": true,
"validate": {
"enum": [
"roundtrip",
"execution"
]
}
}
],
"interface": [
{
"name": "SecondsDiff",
"label": "SecondsDiff",
"type": "any"
},
{
"name": "DaysDiff",
"label": "DaysDiff",
"type": "any"
}
]
}
}
]
}
],
"metadata": {
"version": 1
}
}
samliew – request private consultation
Join the Make Fans Discord server to chat with other makers!