To refresh the page such that a field can autorun/detect the given py code to find the difference between two dates. ( and "contract_expiry_date")

Hey guys,
I have a field named “days_to_sign_off” which will calculate the days between today and a date entered in another field named “contract_expiry_date”. What I need is when I am looking the page today and the difference between the dates ( and contract expiry date) is 10 , then when I look tomorrow, the difference should be 9 automatically.

This is my code to find the difference between dates and it is working:

def validate(self):
if lists.contract_expiry is not None:
today = datetime.strptime(str(, “%Y-%m-%d”).date()
con_exp__date = datetime.strptime(str(lists.contract_expiry), “%Y-%m-%d”).date()
delta = str(con_exp__date - today)
differenz = delta[:(len(delta)) - 9]

Please do help me with a solution.

Use scheduler event hook to update a document.


it worked, Thank You @Ponnusamy_V