Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
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')

)

  • Pstork1 Profile Picture
    66,968 Most Valuable Professional on at
    Re: Filter Query by date field

    The [0] isn't extra.  That is what gives you the first entry in the array instead of the array.  What appears to be missing is the field name that contains the value you want to format.

  • nvpc Profile Picture
    on at
    Re: Filter Query by date field

    Thanks for your reply, I did try the code above that you provided but I believe it has an extra [0]) so I tried without it. 

    split(item()?['Initial Assigned Date'], '"')

    but got the following error:

    The execution of template action 'Filter_array' failed: The evaluation of 'query' action 'where' expression '@greaterOrEquals(split(item()?['Initial Assigned Date'], '"'), split(item()?['Initial Assigned Date'], '"'))' failed: 'The template language function 'greaterOrEquals' expects all of its parameters to be either integer or decimal numbers. Found invalid parameter types: 'Array'.'.

    As per your suggestion starting from the inside; when I run the code I can see the raw input as coming across as "44818.7389351852" see below;

    nvpc_1-1679267267077.png

    so if the code you provided removes the "" then it leaves it as 44818.738935 now to convert this to an integer or a float but this the code to do this is not working, see below

    int(formatNumber(float(split(item()?['Initial Assigned Date'], '"')[0]), '0', 'en-us'))

    however; if I hard coded see below, it works.

    int(formatNumber(float(split('44818.7389351852''"')[0]), '0''en-us'))
  • Pstork1 Profile Picture
    66,968 Most Valuable Professional on at
    Re: Filter Query by date field

    Then I would use a Compose to start from the inside and work out to see exactly what values you are working with.  I would start with this to make sure it can be cast to a floating point number

    split(item()?['Initial Assigned Date'], '"')[0])
  • nvpc Profile Picture
    on at
    Re: Filter Query by date field

    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

     

     

  • Pstork1 Profile Picture
    66,968 Most Valuable Professional on at
    Re: Filter Query by date field

    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
    Re: Filter Query by date field

    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.'.

  • nvpc Profile Picture
    on at
    Re: Filter Query by date field

     

    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'.

  • grantjenkins Profile Picture
    11,059 Super User 2025 Season 1 on at
    Re: Filter Query by date field

    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
    Re: Filter Query by date field

    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'))

     

  • nvpc Profile Picture
    on at
    Re: Filter Query by date field

    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')
    )

     

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492