Hi.
I have a flow that executes a paginated report. The report has 2 parameters, one of which is FiscalYear. I'm trying to create an expression to give me the current fiscal year as an integer, but I keep getting errors. Here's what I currently have:
if(int(formatDateTime(utcNow(),'MM')) > 6, int(formatDateTime(utcNow(),'yyyy')) + 1, int(formatDateTime(utcNow(),'yyyy')))
Maybe I need to pursue a different strategy? Thanks for any thoughts you may have!
Solved! Go to Solution.
Hi @nich3play3r,
You are pretty close to the solution. Just replace > and + by the greater and add functions. You can also remove the formatdatetime and directly put the format within the UtcNow function
Try the expression below instead:
if(greater(int(utcNow('MM')), 6), add(int(utcNow('yyyy')), 1), int(utcNow('yyyy')))
Hi @nich3play3r,
You are pretty close to the solution. Just replace > and + by the greater and add functions. You can also remove the formatdatetime and directly put the format within the UtcNow function
Try the expression below instead:
if(greater(int(utcNow('MM')), 6), add(int(utcNow('yyyy')), 1), int(utcNow('yyyy')))
Thank for you for this, @Expiscornovus . This value is such a common need for me, I should really take the time to document its creation across all the languages I'm frequently dabbling in. Also, a follow up, if you have time:
I see you're doing this as an variable. I went straight for a Compose step, though I suppose I could also simply add your expression directly into my ParametervaluesValue box in my Export to File For Paginated Reports step. Would initializing a variable still be your recommedation, given these other options?
Thank you again for your time and your clear, concise answer.
Hi @nich3play3r,
Yes, you should be able to use the expression directly into the parametervalues box/field.
You do not need a compose or initialize variable action. My screenshot was just an example 😁