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

APEX or Formula: Adding # of Hours (Custom Number field) to Date/Time Field
Hi All,
Please bear with me since I am a complete newbie in Apex. I have a requirement that whatever number is entered on a custom number field, it will add to hours of Date/Time Field.
Ex. Date/Time field = 07/10/2015 1:37 AM
Custom_Number__c = 5
Answer should be = 07/10/2015 6:37 AM
I would be glad if someone can share their codes. Thank you.
Please bear with me since I am a complete newbie in Apex. I have a requirement that whatever number is entered on a custom number field, it will add to hours of Date/Time Field.
Ex. Date/Time field = 07/10/2015 1:37 AM
Custom_Number__c = 5
Answer should be = 07/10/2015 6:37 AM
I would be glad if someone can share their codes. Thank you.
try this
All Answers
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_datetime.htm
so - in apex:
DateTime newDT = oldDT.addHours(Custom_Number__c);
try this