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

View solution in original post

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

View solution in original post

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

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

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

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Users online (84,010)