function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dnewportdnewport 

Extracting Hours from a Date/Time Field and Using the result to Update a field

I am attempting to extract the hours from a custom time/date field so that if the formula returns true then the priority custom field will change values. 
 
Let me explain more in detail what I am doing...a lead has a preferred contact time.  If the lead preferred contact time equals NOW plus 2 hours, then the lead becomes High (Red Flag) priority.  When the lead preferred contact time has expired, then the lead priority returns to normal (in our case...a Yellow Flag).
 
I have looked at formulas to extract the GMT from a date/time field, but am running into problems writing the formula with no syntax errors.
 
I already have a "Priority Formula" created to change the priority flag of a lead based on lead status and a 12 hour time period.  I don't know if I need to add to that formula or create a workflow rule based on a new formula with a field update.
 
The current Priority Formula (which is working) is:
IMAGE(
CASE( Status,
"Open", IF(NOW() - CreatedDate < 0.5, "/img/samples/flag_green.gif","/img/samples/flag_red.gif"),
"Message 1", "/img/samples/flag_yellow.gif",
"Message 2", "/img/samples/flag_yellow.gif",
"Message 3","/img/samples/flag_yellow.gif",
"Message 4","/img/samples/flag_yellow.gif",
"Message 5","/img/samples/flag_red.gif",
"Contacted","/img/samples/flag_yellow.gif",
"/s.gif"),
"priority flag")
 
Any help would be appreciated.
dnewportdnewport

This is what I have so far:

 IF(NOW()=MID ( TEXT ( Contact_Time__c ), 12, 5),"/img/sampes/flag_red.gif","/img/samples/flag_yellow.gif")

But I receive an error stating "Incorrect parameter for function =(). Expected DateTime, received Text."

dnewportdnewport

Ok...I am taking a new approach.  I am first going to convert the time of day into text to relate to EST (our timezone and that of all of our current clients).  So, I have the formula listed below, but the sytax checker states that I am missing a ).  I am at a loss as to where.

CASE(MID ( TEXT ( NOW() ), 12, 2)
0, 8 PM,
1, 9 PM,
2, 10 PM ,
3, 11 PM,
4, 12 AM,
5, 1 AM,
6, 2 AM,
7, 3 AM,
8, 4 AM,
9, 5 AM,
10, 6 AM,
11, 7 AM,
12, 8 AM,
13, 9 AM,
14, 10 AM,
15, 11 AM,
16, 12 PM,
17, 1 PM,
18, 2 PM,
19, 3 PM,
20, 4 PM,
21, 5 PM,
22, 6 PM
23, 7 PM,
0)