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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Filter Query by date f...
Power Automate
Unanswered

Filter Query by date field

(0) ShareShare
ReportReport
Posted on by

I need to filter date data being imported from excel using the "Filter Query" see below:

nvpc_0-1678773716198.png

nvpc_1-1678773818866.png

the 1st circled is the query, I need to filter data that is 18 month and newer from todays date; 

 'Assigned Date' eq dateDifference(utcNow(),18)

 

the 2nd circled is that the 'DateTime Format' has to be Serial Format as I have too many working flows where I'm having to convert using the following formula:

if(empty('Assigned Date'),

null,

addSeconds('1899-12-30',int(formatNumber(mul(float('Initial Assigned Date'),86400),'0','en-us')),'MM-dd-yyyy')

)

Categories:
I have the same question (0)
  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    i could not understand what is ur question here?

     

    Could you explain it properly?

     

     

  • nvpc Profile Picture
    on at

    Hi Nived,

    The question: I need to filter data being imported; I want to use the "Filter Query" and pass ODATA filter query. The field I need to use is 'Assigned Date', I need 12 months of data from today's date. if today is 3/14/2023 then I would need data from 3/14/2022 to 3/14/2023. ex. 'Assigned Date' >= 3/14/2022.

    Thanks in advance.

    nv

  • grantjenkins Profile Picture
    11,063 Moderator on at

    With List rows present in a table you can't use fieldnames that have spaces within the Filter Query. So, you would need to return all rows, then use a Filter array to filter out the data you want.

     

    I would still suggest setting the DateTime Format to ISO 8601 to return dates in ISO format rather than Serial. If Dates are blank, then you need to cater for this regardless of format.

     

    See full flow below. I'll go into each of the actions.

    grantjenkins_0-1678867433294.png

     

    List rows present in a table using ISO 8601.

    grantjenkins_1-1678867477621.png

     

    Filter array would use the following expression to return items that are less than 18 months old and exclude any items where the date is empty.

    @And(
     not(equals(item()?['Assigned Date'], '')),
     greaterOrEquals(item()?['Assigned Date'], addToTime(utcNow(), -18, 'Month'))
    )

    grantjenkins_2-1678867553629.png


    ----------------------------------------------------------------------
    If I've answered your question, please mark the post as Solved.
    If you like my response, please consider giving it a Thumbs Up.

  • nvpc Profile Picture
    on at

    Thank you Grant,

    nvpc_0-1678913146271.png

    That worked! I will use this in the future. However; as I mentioned before I have too many flows to convert to ISO 8601 and had experienced issues converting dates that is the reason I used the code below on my date fields and it works fine.

    if(empty('Initial Assigned Date'),
    null,
    addSeconds('1899-12-30',int(formatNumber(mul(float('Assigned Date'),86400),'0','en-us')),'MM-dd-yyyy')
    )

     

  • nvpc Profile Picture
    on at

    I have gotten closer by using Filter array:

    nvpc_0-1678941192353.png

    Again, I have to use 'Serial Number' for DateTime Format, so the date fields are coming in as serial number format for example "Initial Assigned Date": "44818.7389351852". the first parameter is expecting an ISO date format, see circled area below.

    nvpc_1-1678941521891.png

    if I hard coded it works fine, example:

    add(div(sub(ticks('2021-09-30T00:00:00Z'),ticks('1900-01-01T00:00:00Z')),864000000000),1),

     

    I need to convert this serial number: "44818.7389351852" into this format 'yyyy-MM-ddThh:mm:ssZ'

    I've tried using the the following but get invalid "Float" error.

    addSeconds('1899-12-30', int(formatNumber(mul(float('Initial Assigned Date'), 864000000000), '0', 'en-us')), 'yyyy-MM-ddThh:mm:ssZ'))

    I also tried using the following but get, template language function 'mul' expects its first parameter to be an integer or a decimal number. 

    int(formatNumber(mul('Initial Assigned Date', 86400), '0', 'en-us')), 'yyyy-MM-ddThh:mm:ssZ'))

     

  • grantjenkins Profile Picture
    11,063 Moderator on at

    Can you try the following:

     

    addSeconds('1899-12-30', int(formatNumber(mul(float(item()?['Initial Assigned Date']), 864000000000), '0', 'en-us')), 'yyyy-MM-ddThh:mm:ssZ'))
  • nvpc Profile Picture
    on at

     

    Getting the following error:

    The execution of template action 'Filter_array' failed: The evaluation of 'query' action 'where' expression '@greaterOrEquals(addSeconds('1899-12-30', int(formatNumber(mul(float(item()?['Initial Assigned Date']), 864000000000), '0', 'en-us')), 'yyyy-MM-ddThh:mm:ssZ'), add(div(sub(ticks(addToTime(utcNow(), -18, 'Month')), ticks('1900-01-01T00:00:00Z')), 864000000000), 1))' failed: 'Value to add was out of range.
    Parameter name: value'.

  • nvpc Profile Picture
    on at

    I have successfully managed to run the flow hard coding the serial number see below;

                                 

    @greaterOrEquals(int(formatNumber(float(split('44818.0000000', '"')[0]), '0', 'en-us')), add(div(sub(ticks(addToTime(utcNow(), -18, 'Month')), ticks('1900-01-01T00:00:00Z')), 864000000000), 1))

     

    But when i try using the item()?['Initial Assigned Date'] I get an error, see below;

     

    The execution of template action 'Filter_array' failed: The evaluation of 'query' action 'where' expression '@greaterOrEquals(int(formatNumber(float(split(item()?['Initial Assigned Date'], '"')[0]), '0', 'en-us')), add(div(sub(ticks(addToTime(utcNow(), -18, 'Month')), ticks('1900-01-01T00:00:00Z')), 864000000000), 1))' failed: 'The template language function 'float' was invoked with a parameter that is not valid. The value cannot be converted to the target type.'.

  • Pstork1 Profile Picture
    69,218 Most Valuable Professional on at

    If you are going to use the value from the List Rows in a Table in a Filter Array with your formula you need to have the advanced setting in the action set to Serial, not ISO 8601.  You are trying to filter using an ISO 8601 string value as a Serial date.  That's why you are getting an error on the query.

  • nvpc Profile Picture
    on at

    Thank you for your response! I do not have datetime format set to ISO 8601, grantjenkins had suggested using that setting but as I explained at the beginning of the post that I have too many flows using Serial Number setting already. So, I do have datetime format set to Serial Number.

    nvpc_0-1679084631323.png

     

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 550

#2
Valantis Profile Picture

Valantis 390

#3
11manish Profile Picture

11manish 348

Last 30 days Overall leaderboard