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
Shubham Sinha 56Shubham Sinha 56 

How to use Minus operator in HTML email template

I have a requirement where i need to show the no. of hours (Now - Created Date) in the email template but I donot want to create a formula field rather want to create the same formula in HTML template itself. 
Could anyone please help me on this.
Best Answer chosen by Shubham Sinha 56
Maharajan CMaharajan C
Hi Shubham,

Please try anyone of the below formulas:

1. Below one will return the values with Decimal Points.
{!Now() - Lead.CreatedDate}

2. Below one will return the values without Decimal Points.
{!TODAY() - DATEVALUE(Lead.CreatedDate)}

Thanks,
Maharajan.C
​​​​​​

All Answers

PriyaPriya (Salesforce Developers) 

Hi Shubham,

You need to add {! } around your formula field in the template. For example you can refer this below link that matched your requirement. 

https://developer.salesforce.com/forums/?id=9062I000000g7ylQAA

Please mark as Best Answer so that it can help others in the future.

Regards,

Priya Ranjan

 

Shubham Sinha 56Shubham Sinha 56
Hi Priya,
Thanks for your reply but i tried this already but it did not help. I tried like this :-
{!Now()} - {!Lead.CreatedDate}  and it gave me result like  4/26/2021 4:24 PM - 4/21/2021. Could you please suggest what I am missing here.
Maharajan CMaharajan C
Hi Shubham,

Please try anyone of the below formulas:

1. Below one will return the values with Decimal Points.
{!Now() - Lead.CreatedDate}

2. Below one will return the values without Decimal Points.
{!TODAY() - DATEVALUE(Lead.CreatedDate)}

Thanks,
Maharajan.C
​​​​​​
This was selected as the best answer
Shubham Sinha 56Shubham Sinha 56
Hi Maharajan,

Would this work in  HTML template. I do not want to create a formula field. I want to use the same formula in the email template but i guess it is not working 
Shubham Sinha 56Shubham Sinha 56
It worked Maharaja. Thanks . One more help for now it is giving the result in days how to change it to hours using same formula