+ Start a Discussion
hy.lim1.3897974166558203E12hy.lim1.3897974166558203E12 

date time (System.now()) value minus numeric field doesnt work

i have a trigger that will update a custom date/time field in my case but it seems like not working

This is my trigger:

c.SLA_Cont_Time__c = System.now() - c.SLA_Days_mins__c;

c.SLA_Cont_Time__c is my custom date/time field and c.SLA_Days_mins__c is a numeric field that i need to minus it to get latest value. but my c.SLA_Cont_Time__c keep getting the System.now() value instead. why it will not take the after subtraction value?

anything wrong?
Best Answer chosen by hy.lim1.3897974166558203E12
Ankit Gupta@ DeveloperAnkit Gupta@ Developer

Hi,

for minus the no of days use adddays() method.

 

try the below code snippet as reference :
datetime d1=system.now().adddays(-4);
system.debug('aa'+d1);

Thanks
Ankit Gupta

 

 

All Answers

Ankit Gupta@ DeveloperAnkit Gupta@ Developer

Hi,

for minus the no of days use adddays() method.

 

try the below code snippet as reference :
datetime d1=system.now().adddays(-4);
system.debug('aa'+d1);

Thanks
Ankit Gupta

 

 

This was selected as the best answer
hy.lim1.3897974166558203E12hy.lim1.3897974166558203E12
Thanks, got it. i use .addminutes()