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 / Good morning, good eve...
Power Automate
Unanswered

Good morning, good evening, good night and good afternoon depending on daytime.

(0) ShareShare
ReportReport
Posted on by

Hi! I have maybe a dumb question, but still 🙂

I need to configurate in my PVA a thing, where person that types "Hello" will get a welcoming message that depends on time of the day. 
I need it like this:
0-3 Good night
4-11 Good morning
12-17 Good afternoon

18-23 Good evening

I have found this message  on this forum with a following expression 

if(greater(int(formatDateTime(utcNow(),'HH')),18),'Good evening',if(greater(int(formatDateTime(utcNow(),'HH')),11),'Good Afternoon','Good Morning'))


and tried to add "night" and "morning" but i got an invalid expression. 
Can someone help me? I have some diffucuilties with "if" expressions so maybe the answer is pretty easy. 

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

    Hi @Anonymous,

     

    I have adjusted it a little bit and I am using the less function instead. Can you try and use this expression and test if that works for you?

    if(less(int(formatDateTime(utcNow(),'HH')),4),'Good Night',if(less(int(formatDateTime(utcNow(),'HH')),12),'Good Morning',if(less(int(formatDateTime(utcNow(),'HH')),18),'Good Afternoon','Good Evening')))
  • Community Power Platform Member Profile Picture
    on at

    Thanks a lot! 🙂 
    That worked. I was wondering if there is any sort of article that can be useful for newbie like me to understand expressions and how they work? I found the official "how to" from microsoft called Use expressions in conditions to check multiple values (unfourtunately i cannot send the link) about expressions but its quite messy for me. But thanks a lot for the answering 🙂 
    oh last but not least, if i want to indicate today as a date (for example 22.03.2021 is today and tomorrow "today" will be 23.03.2021) should i use this form formatDateTime(utcNow(),1),'DD.MM.YYYY' ? Im living in the EU so i need DD.MM. 🙂 

  • Yourmom0324 Profile Picture
    2 on at

    Is there a way to have the message to say Good Morning, Good Afternoon, and Good Evening? 
    I have checked several threads and nothing seems to work. I keep getting Expression is not valid. I do not know how to edit the code to only display those three items. 

  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @Expiscornovus  & @Anonymous 

     

    Is this worked for you?

     

    My UK time is 23:47 nearly midnight.

     

    Use the same expression as suggested.

     

    if(less(int(formatDateTime(utcNow(),'HH')),4),'Good Night',if(less(int(formatDateTime(utcNow(),'HH')),12),'Good Morning',if(less(int(formatDateTime(utcNow(),'HH')),18),'Good Afternoon','Good Evening')))
     

    image.png

     

    Not sure that expression is quite correct.

     

    Thanks

  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @abm,

     

    Yeah, it might be faulty, let me investigate. Was that UTC time in your test? (23:47).

     

    Got a similar message from somebody else yesterday actually. 

     

    Ignore this below, the contains approach does not work

    As a workaround I came up with a new expression in that other threat. That one might be better, can you double check if that works better?

     

    if(contains(range(0,3), int(utcNow('HH'))), 'Good Night', if(contains(range(4,11), int(utcNow('HH'))), 'Good Morning', if(contains(range(12,17), int(utcNow('HH'))), 'Good Afternoon', 'Good Evening')))

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

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard