I would solve it with a date field (to record the last changed date), a number formula field (to calculate the number of days since the change), and a workflow rule to set the date. For example, to monitor the opportunity stage field, you might do the following:
Field To Monitor: StageName
Date Field: Stage_Last_Changed_Date__c
Number Formula Field: ...
Going off the comments, it sounds like your issue is:
You have a template that you want the Title tag to be the subject
This template is being used as a template and utilized in multiple places
The subject is set inside the emails using the template, not the template
meaning that the subject var value is set AFTER the title html is processed.
You want the ...
option 1,no SSJS.
use a nested SELECT expression to populate the "TOP" number in SQL to avoid SSJS.
For this, I made a pretty terrible example, but you get the idea:
one DE "controlDE" where I save a number.
You could populate this in any way that matches your usecase.
numberOfRecords (number) // id (text)
if in ...
You have to enable Einstein Form Reader Pilot in your orgs and contact Salesfoce AE for the same.
If you would like to try out Form Reader Capabilities, there is a Appexchange's managed package called "Extension for Einstein Form Reader" which is free of cost.
Below is the link for the AppExchange Product.