web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Getting just the Month...
Power Automate
Unanswered

Getting just the Month number from a Date field in filter query

(0) ShareShare
ReportReport
Posted on by 34

I have a Date field in my list and just want to extract the Month number.

 

Essentially i would like the query to be something like:

formatDateTime('Date','MM') eq '03'.
In order to get only the values from March from the list.
 
The above expression does not work.
How can i achieve this?
 
Categories:
I have the same question (1)
  • efialttes Profile Picture
    14,756 on at

    Hi!

    Sharepoint list?

    If so, are getting the info via 'Get item' or via trigger 'When a item is created'?

    Or, did you get it by means of 'Get items', and you wanna get the trick inside an 'Apply to each' / 'Select' / 'Filter array'?

    Thanks!

  • CU25091147-0 Profile Picture
    34 on at

    My trigger is from a Powerapp. But I am using Get Items to get items from the Sharepoint list based on the filter query to then Apply to Each from the result. The filter query is based based on the Date from the Sharepoint list and the month number eq value is fed from the Powerapp. For an example, I am getting the month value in Powerapps using Month(StartDate)

  • efialttes Profile Picture
    14,756 on at

    Hi!

    I think the problem is, when using oDATA expression in your Filter Query input, you need the following sintax:

     

    ColumnName operator value

     

    ...but you cannot manipulate your column name by using

     

    expression(Columname) operator value

     

    The approach you have designed can work if you replace Filter Query and use a 'Filter array' action block just after 'Get items' instead, just need to assign 'Get items' output as 'Filter array' input. 

    Does this new approach make sense to you?

    Please let me know and we will start working on it

  • CU25091147-0 Profile Picture
    34 on at

    Okay. Its seems strange that you cant essentially substring a column before a compare.

     

    I have added a Filter array with:

     

    {
        "inputs": {
            "from""@body('Get_items')?['value']",
            "where""@equals(formatDateTime(item()?['Date'], 'MM'), 03)"
        }
    }
     
    Or adnaced. @equals(formatDateTime(item()?['Date'], 'MM'), 03)
     
    So now i need to Apply to each on the body of this?
     
    Thanks.
  • Verified answer
    efialttes Profile Picture
    14,756 on at

    Hi!

    No need for an 'apply to each' yet.

    Please note the following

    equals(formatDateTime(item()?['Date'], 'MM'), '03')

    formatDateTime() output is a string, so you need to wrap 03 with single quotes

     

    Can you run manually your flow, and inspect Filter array outputs? You will probably get an array of items matching your requirements? Hope there are just a few, if not we can add a 'SElect' action block just after the 'Filer array' for troubleshooting purposes

    Thanx!

  • CU25091147-0 Profile Picture
    34 on at

    Thanks, that has worked. Apply to Each on the body of Filter array is working correctly as well and producing the output i am expecting. I think this is solved.

     

    Thank you for your help.

     

     

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.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard