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
Charni WigginsCharni Wiggins 

DateTime formula field returning null - add time to date

I am trying to create a formula that adds a specified time to a date. It keeps returning empty at the moment for some reason. I need it for a process which will send an email at this datetime. This is what I have tried so far. 

Follow Up Time: Time 
Consent Email Sent: DateTime 
DATETIMEVALUE(TEXT( Consent_Email_Sent_INTERNAL_USE_ONLY__c ) +  TEXT(Follow_Up_Time__c))
DATETIMEVALUE(TEXT(Consent_Email_Sent_INTERNAL_USE_ONLY__c)&" "&TEXT(Follow_Up_Time__c))

Follow Up Time: Number 
Consent Email Sent: DateTime 
DATETIMEVALUE(TEXT(Consent_Email_Sent_INTERNAL_USE_ONLY__c) + TEXT(Follow_Up_Time__c) + ':00:00')

Much appreciate any help! 
Best Answer chosen by Charni Wiggins
Steven NsubugaSteven Nsubuga
Seems you can only add or subtract hours to or from a date time field. 
Assuming that Follow_Up_Time__c is a Number field showing the number of hours 
Consent_Email_Sent_INTERNAL_USE_ONLY__c + (Follow_Up_Time__c/24)
See this documentation (https://help.salesforce.com/articleView?id=000221466&type=1).


 

All Answers

Steven NsubugaSteven Nsubuga
Seems you can only add or subtract hours to or from a date time field. 
Assuming that Follow_Up_Time__c is a Number field showing the number of hours 
Consent_Email_Sent_INTERNAL_USE_ONLY__c + (Follow_Up_Time__c/24)
See this documentation (https://help.salesforce.com/articleView?id=000221466&type=1).


 
This was selected as the best answer
Charni WigginsCharni Wiggins
Hi Steven,

Thank you for your reply. It seems to be returning 01:00 for the time but should be 08:00. The number field is a formula number field with 8, is that ok?
Steven NsubugaSteven Nsubuga
The number field is a formula number field with 8, is that ok?
Yes, assuming that your intention is to add 8 hours to the Consent_Email_Sent_INTERNAL_USE_ONLY__c date time
Charni WigginsCharni Wiggins
Hi Steven, I changed the date field to date/time and now it works. I wanted to make it 8am on that date but will just use if's to add/subtract different hours depending on the time value - unless you know another way? 

Thank you,

Charni
Steven NsubugaSteven Nsubuga
I currently have no idea on how else it can be done.
Charni WigginsCharni Wiggins
Hi Steven,

No worries, thank you for your help! :)