Print this page

How to determine if Cases were Created Outside of Business Hours?

Knowledge Article Number 000006143
Description

What is the most effective way to determine if the created date/time of a case is outside of the business hours associated with the case?

Business hours are M-F 8:00 a.m. - 5:00 p.m.

For example: If a case was created on Friday at 5:01 p.m. or on Saturday they would be flagged as being created outside of the business hours associated with the case.

Resolution

OR(
RecordTypeId="01260000000U9fv",
RecordTypeId="01260000000U9fq")&&
NOT(
AND(
IF(
RIGHT(
LEFT( Expected_Meeting_Time__c,2),1)=":",
REGEX(LEFT(Expected_Meeting_Time__c,1),"[1-9]"),
REGEX(LEFT(Expected_Meeting_Time__c,2),"[1-9]{2}")),

LEFT(RIGHT( Expected_Meeting_Time__c,10),1)=":",
REGEX(LEFT(RIGHT( Expected_Meeting_Time__c,9),2),"[0-9]{2}"),
LEFT(RIGHT( Expected_Meeting_Time__c,7),1)=" ",
OR(
LEFT(RIGHT( Expected_Meeting_Time__c,6),2)="AM",
RIGHT(LEFT( Expected_Meeting_Time__c,6),2)="PM"),
LEFT(RIGHT( Expected_Meeting_Time__c,4),1)=" ",
OR(
RIGHT( Expected_Meeting_Time__c,3)="EST",
RIGHT( Expected_Meeting_Time__c,3)="PST",
RIGHT( Expected_Meeting_Time__c,3)="CST",
RIGHT( Expected_Meeting_Time__c,3)="MST"
)
)
)

If no record type is used then the formula can be:

NOT(
AND(
IF(
RIGHT(
LEFT( Expected_Meeting_Time__c,2),1)=":",
REGEX(LEFT(Expected_Meeting_Time__c,1),"[1-9]"),
REGEX(LEFT(Expected_Meeting_Time__c,2),"[1-9]{2}")),

LEFT(RIGHT( Expected_Meeting_Time__c,10),1)=":",
REGEX(LEFT(RIGHT( Expected_Meeting_Time__c,9),2),"[0-9]{2}"),
LEFT(RIGHT( Expected_Meeting_Time__c,7),1)=" ",
OR(
LEFT(RIGHT( Expected_Meeting_Time__c,6),2)="AM",
RIGHT(LEFT( Expected_Meeting_Time__c,6),2)="PM"),
LEFT(RIGHT( Expected_Meeting_Time__c,4),1)=" ",
OR(
RIGHT( Expected_Meeting_Time__c,3)="EST",
RIGHT( Expected_Meeting_Time__c,3)="PST",
RIGHT( Expected_Meeting_Time__c,3)="CST",
RIGHT( Expected_Meeting_Time__c,3)="MST"
)
)
)





promote demote