You need to sign in to do that
Don't have an account?
Shariq Abbasi.ax705
How to use addhours?
I have two fields..
1- Date_Time_1_c
2- Date_Time_2_c
I want the default value of Date_time_2_c to be Date_Time_1_c+1 hour. How do I use addhours here? or is there any other solution?
Thanks,
Shariq
I just tested it on my Developer SFDC.org and it worked fine.
What is the datatype of the fields that you are using?
All Answers
Date/Time Calculations in Formula Fields, Workflow Field Updates and Validation Rules
Date/Time Calculations in Formula Fields, Workflow Field Updates, and Validation Rules can be difficult to understand. A common Date/Time formula to calculate the time since a record has been created like:
NOW() - CreatedDate
returns a numeric value in the format 99.99XX depending on the number of decimal places specified.
The value to the left of the decimal is intuitively the number of days. The value to the right of the decimal is a representation of the portion of a 24 hour period of the hours and minutes returned by the calculation.
A returned calculation value of 2.25 represents 2 days and 6 hours.
.25 * 1440 (the number of minutes in a 24 hour period) = 360 minutes
360/60 minutes = 6 hours
Steve,
This is the error I get..
Error: Field Date_Time_Start__c may not be used in this type of formula
I just tested it on my Developer SFDC.org and it worked fine.
What is the datatype of the fields that you are using?
It is working. I was doing something wrong.
Thanks and yeah, I know I owe you a beer (before you say it yourself) :smileywink:
Steve,
What if I don't want to use a formula field. I just want the field to have the default value of start time+1. I have to set this up during creating this field under the "defualt value" but it is not letting me do it. The field's data type is day/time.
Formula fields can't be edited, if the field needs to be edited then you need to create a Workflow Rule with a Workflow Action: Field Update.
Formula fields can't be edited, but it's possible to work around them. For example, on one object I have a field called Corrected_Entry_Date__c, date type. There is a formula field called Entry_Date__c with this formula:
if (isnull( Corrected_Entry_Date__c ), CreatedDate , Corrected_Entry_Date__c)
That way, it uses CreatedDate unless told otherwise. The same thing can be done for your datetime add-an-hour formula; create a formula field and an editable field, and use your math formula unless there's something in the editable field.
Let me know if I didn't explain this well.
Jeremy