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
Tracy Oden 31Tracy Oden 31 

how to add a second to a formula date and time field

This should be simple, but I can't figure it out. How do I add a second to a date and time field in a formula? I have a 'end' date and time field. I want my formula field to show 'next' available date and time. The next available should be one second from end date and time.
anil jadhav 8anil jadhav 8
Hi Tracy,

This might help you. 
https://success.salesforce.com/ideaView?id=08730000000BrLJ

There is no way to add seconds to data fields.

The only other way is convert time(Hour:Min:Sec) to seconds and add next onesecond to it and again reconvert to time. But its hectic.

Regards,
Anil
Akhil AnilAkhil Anil
Hi Tracy,

I really wonder what action are you going to perform just one second after the endate ? I mean I already lost close to 120 seconds while writing this answer ;)

Anyway here goes your solution.

To add a second to your Date/time field you need find it's fractional value lby dividing it with the seconds value in 24 hours.

1 second = 1/24*60*60 = 1/86400 = 0.000011

So simple add it to your Date/Time field like this
 
(EndDate__c + 0.000011)

Hope that helps !
Tracy Oden 31Tracy Oden 31
Tried this already, but the calculation doesn't show the additional second on the date and time field. This needed for an automated process.
Tracy Oden 31Tracy Oden 31
Thanks to the both of you.
David Tissen 7David Tissen 7
@Akhil Anil: Your Code Sample is correct. Your Explanation Sample not.

Wrong: 1 second = 1/24*60*60 = 1/86400 = 0.000011
Correct: 1 second = 1/(24*60*60) = 1/86400 = 0.000011