Flows - need todays date as YYYY-MM-DD to use in If block

Hi, i’m new to flows so aplogies if this is simple but i couldn’t see an answer anywhere.

As part of my flow, i need to use today’s date, as a string in format YYYY-MM-DD, as a variable in an If block. In the screenshot i need to replace “2024-02-26” with a varibale for current date

I was able to set a global variable in a pre-request script for a GET API call using:
const moment = require(‘moment’);
pm.globals.set(“currentDate”, moment().format(“YYYY-MM-DD”));

However, it doesn’t appear that i can reference the global variable in the IF block and i can’t see how to set a local variable from the global.

Any help would be much appreciated

Hi @ah-potts

Welcome to the forums!

Try this instead of your hard-coded string:

$split($now(), 'T')[0]

$now() will get you the full current date and time, splitting on T gives you just the date in the format you want.

Here’s a link to the docs how $now is used. I realize it was missing from our reference, so i’m going to add it there.

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