Search code examples
arrayspowerappspower-automatepowerapps-formula

How do you add the dynamic date filter to the query filter in PowerAutomate?


I am trying to add a filter to look back 30 days and 180 forward, this giving a really hard time, and I tried everything possible to make this work, but I am stumped and could not figure it out. Can anybody please tell me, how to make this work? I am trying every single option online for a week now. This date filter killing me. 

What I am trying to Filter (createdDateTime)

enter image description here

What I tried so far

FormatDateTime('createdDateTime', 'yyyy-mm-dd') ge formatDateTime(addDays(utcNow(),-30),'yyyy-MM-dd') 
AND formatDateTime(addDays(utcNow(), 180),'yyyy-MM-dd')


FormatDateTime(triggerBody()?['createdDateTime'],'yyyy-MM-dd') ge formatDateTime(addDays(utcNow(),-30),'yyyy-MM-dd')

Getting another error for above "One or more fields provided is of type 'Null', a different type is expected."

enter image description here

enter image description here

Thank you so much


Solution

  • Try something like this:

    From Date:

    formatDateTime(triggerBody()?['From'],'yyyy-MM-dd')
    

    To Date:

    formatDateTime(triggerBody()?['To'],'yyyy-MM-dd')
    

    formatDateTime(triggerBody()?['From'],'yyyy-MM-dd')