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 / Search query using add...
Power Automate
Answered

Search query using addHours in an expression not resulting in correct results in GetEmails v3

(0) ShareShare
ReportReport
Posted on by 9
I am using GetEmails v3 to look for emails with certain subjects, senders, etc to file them after they are nn hours old. 
 
To determine the receipt time, I'm using this Search Query:
tcs5t_0-1660940454899.png

where the expression is:  formatDateTime(addHours(utcNow(),-1),'yyyy-MM-ddThh:mm:ss')     - to identify messages over an hour old.

 

Messages are identified and moved based on this expression, but it seems to only affect messages prior to today.  Even if I change addHours to addMinutes and use -60 minutes, it appears to only affect messages received prior to today. 


Any suggestions?

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,195 Most Valuable Professional on at

    Hi @tcs5t,

     

    In your Search query in the screenshot I see your condition is reveived date time needs to be less than or equal to yesterday.

     

    Can you switch your operator to the greater than sign to see if that makes a difference? (received >= )

  • tcs5t Profile Picture
    9 on at

    Thanks @Expiscornovus, I did try that.  It had the effect of finding all messages matching the query, received since an hour ago. 

    So my test results are this:
    received<= [fx formatDateTime(addHours(utcNow(),-1),'yyyy-MM-ddThh:mm:ss')] finds everything yesterday and earlier.

    received>= [fx formatDateTime(addHours(utcNow(),-1),'yyyy-MM-ddThh:mm:ss')] finds everything an hour ago and later.

     

    Goal:  Find everything an hour ago and earlier.  I'm not sure why the first query results only in finding items received the yesterday. 

     

    Thanks for the reply - I really appreciate it.

     

  • Verified answer
    Expiscornovus Profile Picture
    33,195 Most Valuable Professional on at

    Hi @tcs5t,


    I did not notice before in your first post. But you are using lower case hh for hours format (12 hour clock).

    Try HH, this will be 24 hour format.

    formatDateTime(addHours(utcNow(),-1),'yyyy-MM-ddTHH:mm:ss')


    With your current format it will probably be an hour very early in the morning. Which probably is the reason why it is retrieving e-mails from yesterday 😉

  • tcs5t Profile Picture
    9 on at

    @Expiscornovus, That's it!!  Thank you so much.  That was the solution. 

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 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard