Solved

Rule for date

  • 21 February 2024
  • 4 replies
  • 53 views

Badge +4

Hello,

 

How I can make a rule to appear a message if the time out of working hours( from 8 to 4)

icon

Best answer by Chris_Ben 21 February 2024, 10:09

View original

4 replies

Userlevel 6
Badge +12

Here’s one way of doing it.

 

Basically you grab the hour component from your date/time control and check to see if it’s earlier than 8 or after 16.  If it’s 16 you also need to check the minutes are not more than 0.

 

For ease of readability I’ve split it into 3 form variables.

 

Create an integer form variable called “Hour”:

convertToNumber(formatDate([Form].[Datetime],"HH"))

 

Create an integer form variable called “Minutes”:

 

convertToNumber(formatDate([Form].[Datetime],"mm"))

 

Create a boolean form variable called “Outside work hours”:

ifElse([Form].[Hour]<8||[Form].[Hour]>16,

    true,

ifElse([Form].[Hour]==16&&[Form].[Minutes]>0,

    true,

false))

 

Now you can write a submit rule:

 

Badge +4

Hello,

 

from where I get 

[Form].[Datetime]

 

Userlevel 6
Badge +12

Hi - that would be whatever you named your date picker control on your form. 

Badge +4

thank you very much

Reply