Issue in getting date for an API using Moment

I'm trying to use Moment to format a date for a workflow I'm trying to dynamically manage.

The purpose of the workflow is to synchronize data from 1 system to another. Here's the flow:

  1. Triggered on a schedule every hour
  2. It will pull survey responses from an API from the last 3 hours
  3. It then uploads those surveys to another service

I'm trying to use Moment to build the timestamps to pull from the API in step 2 above using the following:

"startDate": {{ moment().subtract(3, 'hours').format("MM/DD/YYYY hh:mm:ss") }},
"endDate": {{ moment().format("MM/DD/YYYY hh:mm:ss") }}

I'm expecting it to output something like this:

"startDate": "01/28/2024 06:30:12",
"endDate": "01/28/2024 09:30:12"

But it's giving me this:


Any idea on why that might be happening?

Thank you!

@Eric_P I think there might be an error with parsing the { } brackets in this? Since its raw json, the javascript between {{}} isn't being run. I'd suggest adding a javascript block prior to this block and have it return the same json object you've written here and place it in the raw body instead.

Thanks so much, @Haseeb1399 — that worked for testing. I ended up using the following configuration:

Which worked end to end in testing — then when I actually ran the workflow, it's not translating correctly:


Any idea why that might be changing the way it's handled when testing vs. when actually running the entire workflow?

By testing you mean running the individual block itself?

Yes — and I also test the entire workflow end to end by starting at the last step and it seems to go through this step OK. Unfortunately, when I actually "Run" the workflow it seems to get stuck. Any tips?

Weird. Have you deployed the latest changes?. If possible share the json of the workflow.

I had deployed the changes but I screwed up something else. NOW I am in a great spot. Thanks so much!