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
image

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
Thanks
Andrew

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.