cancel
Showing results for
Did you mean:
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
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')))``
3 REPLIES 3
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')))``
Frequent Visitor

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

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.

Announcements

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

#### A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

#### Register for a Free Workshop

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