As the title reads, do you know why this isn’t working? keeps the date on the weekend.
Welcome to the Make community!
To allow us to assist you, please provide the following:
1. Scenario blueprint
Please export the scenario blueprint file to allow others to view the mapped variables in the module fields. At the bottom of the scenario editor, you can click on the three dots to find the Export Blueprint menu item.
2. Output bundle of module 9
Please provide the output bundles of the module [9] by running the scenario (or get from the scenario History tab), then click the white speech bubble on the top-right of each module and select “Download input/output bundles”.
A.
Save each bundle contents in your text editor as a bundle.txt
file, and upload it here into this discussion thread.
B.
If you are unable to upload files on this forum, alternatively you can paste the formatted bundles in this manner:
Here are two ways to format text so that it won’t be changed by the forum:
A. Type code block manually
Add three backticks ```
before and after the content/bundle, like this:
```
content goes here
```
B. Highlight and click the format button in the editor
Providing the input/output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.
Following these steps will allow others to assist you here. Thanks!
Welcome to the Make community!
According to the Tokens you can use to format a date variable, you can use d
to get day of week.
I think your mistake is adding double quotes around the date format.
e.g.:
{{if(formatDate(9.mappable_column_values.date_range.to; "d") >= 5; addDays(9.mappable_column_values.date_range.to; (formatDate(9.mappable_column_values.date_range.to; "d") - 4) * -1); 9.mappable_column_values.date_range.to)}}
Output
For more information, see Date Formats in the Help Center.
Hope this helps! Let me know if there are any further questions or issues.
— @samliew
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": "OriginalDate",
"value": "{{9.mappable_column_values.date_range.to}}"
},
{
"name": "DayOfWeek",
"value": "{{formatDate(9.mappable_column_values.date_range.to; \"d\")}}"
},
{
"name": "IsFriSat",
"value": "{{formatDate(9.mappable_column_values.date_range.to; \"d\") >= 5}}"
},
{
"name": "DaysDiff",
"value": "{{(formatDate(9.mappable_column_values.date_range.to; \"d\") - 4) * -1}}"
},
{
"name": "NewDate",
"value": "{{if(formatDate(9.mappable_column_values.date_range.to; \"d\") >= 5; addDays(9.mappable_column_values.date_range.to; (formatDate(9.mappable_column_values.date_range.to; \"d\") - 4) * -1); 9.mappable_column_values.date_range.to)}}"
},
{
"name": "NewDateFormatted",
"value": "{{formatDate(if(formatDate(9.mappable_column_values.date_range.to; \"d\") >= 5; addDays(9.mappable_column_values.date_range.to; (formatDate(9.mappable_column_values.date_range.to; \"d\") - 4) * -1); 9.mappable_column_values.date_range.to); \"YYYY-MM-DD\")}}"
}
],
"scope": "roundtrip"
},
"metadata": {
"designer": {
"x": 299,
"y": -1
},
"restore": {
"expect": {
"variables": {
"items": [
null,
null,
null,
null,
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": "OriginalDate",
"label": "OriginalDate",
"type": "any"
},
{
"name": "DayOfWeek",
"label": "DayOfWeek",
"type": "any"
},
{
"name": "IsFriSat",
"label": "IsFriSat",
"type": "any"
},
{
"name": "DaysDiff",
"label": "DaysDiff",
"type": "any"
},
{
"name": "NewDate",
"label": "NewDate",
"type": "any"
},
{
"name": "NewDateFormatted",
"label": "NewDateFormatted",
"type": "any"
}
]
}
}
]
}
],
"metadata": {
"version": 1
}
}
Hope this helps! Let me know if there are any further questions or issues.
— @samliew
Wow, Thank you so much!
This worked, I appreciate the help!