Hello
I need to convert months to their respective quarters, any idea why the below does not work?
if(int(formatDateTime(utcNow(),'M'))<4,'Q1',if(int(formatDateTime(utcNow(),'M'))<7,'Q2',if(int(formatDateTime(utcNow(),'M'))<10,'Q3','Q4')))
Thanks!
I don't think that will work in your use case.
More info: Standard date and time format strings | Microsoft Docs
@joelzehring I think the problem is that I used 'M' instead of 'MM'. I really wanted to use e.g. 1 for January and not 01. Isn't it possible? Why it results in an error?
I'm not able to reproduce that error... Can you share a screenshot of where you're using this line of code and any modifications you may have made?
Thanks but I get the error:
The template language function 'int' was invoked with a parameter that is not valid
Any ideas?
Nested "if" expressions can be a pain, so I took a slightly different approach. The below expression is just returning the quarter number, which can be concatenated with a "Q" later:
if(greater(mod(int(utcNow('MM')),3),0), add(div(int(utcNow('MM')),3),1), div(int(utcNow('MM')),3))
Hi @PowerAutomate3,
Instead of the < character you could use the less function in your expression.
You can also simplify the expression a bit. You can remove the formatDateTime functions. Try the expression below.
if(less(int(utcNow('MM')), 4), 'Q1', if(less(int(utcNow('MM')), 7), 'Q2', if(less(int(utcNow('MM')),10), 'Q3', 'Q4')))
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Ragavendar Swaminatha Subramanian as our September…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Michael E. Gernaey 783 Super User 2025 Season 2
Tomac 515 Moderator
trice602 299 Super User 2025 Season 2