cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SpaceNudeln
Frequent Visitor

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

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Dual Super User
Dual Super User

Hi @SpaceNudeln,

 

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

View solution in original post

3 REPLIES 3
Expiscornovus
Dual Super User
Dual Super User

Hi @SpaceNudeln,

 

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

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
New Member

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. 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (2,602)