We want to place a logical unit with the function Time (GetCurrentDateTimeUtc ()) and where the range is from 7:00 am to 8:30 pm, we are in Ecuador with time (GMT -5), but we know you that UTC is 12 to 01:30 and the truth is that with the following expression: Hour(GetCurrentDateTimeUtc())>=12 and Hour(GetCurrentDateTimeUtc())<01:30 is not obeying the decision in the Architect. How should the expression be correctly so that it can be fulfilled and function correctly?
Thanks, i understand clearly. But when placing any hour less than or equal to 24 it works. If it is an hour greater than or equal to 00 or 01, the rule stops working.
A number cannot be both greater than 12 and less than one. The Hour function returns the hour of the given time in 24-hour format, that is a value from 0 to 23. The PM hours are 13-23; 1PM = 13, 2PM = 14, 3PM = 15, etc. 12AM = 0
It is clear, but when you are in a time zone (GMT -5), how should the function be? That is the doubt. For example, when you have 7 in the morning here, in UTC it would be 12. Since you must add 5 for the time use 7 + 5 = 12.
Hour(GetCurrentDateTimeUtc()) >= 12 and
(Hour(GetCurrentDateTimeUtc()) <= 13 and Minute(GetCurrentDateTimeUtc()) <= 30)
Hour(GetCurrentDateTimeUtc()) >= 12 checks if the current time is equal to or after to 12:00 UTC, which is 7 AM your time.
(Hour(GetCurrentDateTimeUtc()) <= 13 and Minute(GetCurrentDateTimeUtc()) <;= 30) checks in the current time is equal to or before 13:30 UTC which is 8:30 AM your time.
Another example:
Calculating 5 PM to 9PM your time. The hour for 5 PM in 24-hour format is 17 (5+12). Then adding your offset it becomes 22 (17+5). The hour for 9 PM in 24-hour format is 21 (9+12), adding your offset it beomes 26 (21+5). Since this value is greater than 24 (the 24-hour format goes from 0 to 23 then starts over), subtract 24 to get 2. So 5 PM to 9 PM your local time is 22 to 2 UTC. The calculation would be
Hour(GetCurrentDateTimeUtc()) >= 22 or Hour(GetCurrentDateTimeUtc()) <= 2
Notice this calculation uses or instead of and. A number cannot be both bigger than 22 and less than 2. The 1st half of the calculation captures from the hours from 22 to 23, and the 2nd half captures the hours from 0 to 2.