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 II

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')))``
2 REPLIES 2
Super User II

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. ๐

Announcements

Check out the new Process Advisor community forum board!

#### Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Check out how to claim yours today!

Top Solution Authors
Top Kudoed Authors
Users online (84,010)