You need to sign in to do that
Don't have an account?

Update a number field based on a date/ time field
I have a custom Object with field "date/time of call" I want another number field to populate based on the time in this field irrespective of the date. For eg - Date / time of Call is 26/6/2016 8.00 AM it should populate 1 for 9 am - 2 10am - 3 .... 5 pm - 10 and so on Attached below for your reference -

So if the Date/Time field is 26/5/2016 4.30 PM , Time of Day field should return 9.
So if the Date/Time field is 26/5/2016 4.30 PM , Time of Day field should return 9.
trigger :
All Answers
trigger :
CASE(
VALUE(LEFT(RIGHT(text( CreatedDate ),9),2)),
6,1,
7,1,
8,1,
9,2,
10,3,
11,4,
12,5,
13,6,
14,7,
15,8,
16,9,
17,10,
18,11,
12
)
But I don't know how it will react with timezone.
Referring this link I found trigger is usefull than formula since manual effort is need in forula to adjust the timezone :
http://salesforce.stackexchange.com/questions/17947/date-is-showing-a-different-date-than-the-date-time-field
But hour() method in apex returns value in local time zone which is usefull here.