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
Meena25Meena25 

Date time

I have used the formula NOW() to update a field based upon criteria. I need to add second ss to that. Please suggest a solution.
Best Answer chosen by Meena25
Meena25Meena25
That didn't work Ajay K Dubedi,
This formula worked for me: SUBSTITUTE(TEXT(fieldname__c - 7/24), 'Z', '')

All Answers

Ajay K DubediAjay K Dubedi
Hi Meena25,
For add seconds use addSeconds Try the following code, it may be helpful for you:
DateTime myDateTime = System.NOW();
System.debug('myDateTime-->'+myDateTime);
DateTime newDateTime = myDateTime.addSeconds(4);
System.debug('myDateTime-->'+newDateTime);
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
Piyush Gautam 6Piyush Gautam 6
Hi Meena,

Change the Field Type to Text and try the below formula:
TEXT(DATEVALUE(NOW()))+'-'+TEXT(TIMEVALUE(NOW()))
It will show results like '2019-06-06-08:25:03.029'

Thanks
Meena25Meena25
Sure, Let me try the options suggested.
Meena25Meena25
That didn't work Ajay K Dubedi,
This formula worked for me: SUBSTITUTE(TEXT(fieldname__c - 7/24), 'Z', '')
This was selected as the best answer