Python syntax to set value of custom field

what is python syntax to set value of custom field by custom app?

The same as any standard field in standard app. Share code to get more help.

i have added custom field named as ‘validity_acc_to_today’ in Bank Gaurantee.
and i want to change it daily
for this I had write this code

task.py is here

def daily():
	e=frappe.db.get_value("Bank Guarantee",None, "end_date")
	n=frappe.utils.nowdate()
	i=frappe.utils.data.date_diff (e, n)
	doc.validity_acc_to_today=i

hooks.py is

scheduler_events = {
 	"all": [
 		"bg.tasks.all"
 	],
 	"daily": [
 		"bg.tasks.daily"
 	],

 	"hourly": [
 		"bg.tasks.hourly"
 	],
 	"weekly": [
 		"bg.tasks.weekly"
 	],
	
 	"monthly": [
 		"bg.tasks.monthly"
 	],
	"cron": {
        "59 10 * * *": [
            "bg.task.every_day_at_10_59"
        ]
},
}

is it r8?
because I’m not getting expected output

Where did you get doc from?

Please wrap your code inside ``` characters to improve readability

task.py

def hourly():
    # stuff to do every 10 minutes
    pass



def all():
    # stuff to do every 10 minutes
    pass



def weekly():
    # stuff to do every 10 minutes
    pass


def monthly():
    # stuff to do every 10 minutes
    pass






def every_day_at_10_59():
    # stuff to do every day at 6:15pm
    	e=frappe.db.get_value("Bank Guarantee",None, "end_date")
	n=frappe.utils.nowdate()
	i=frappe.utils.data.date_diff (e, n)
	cur_frm.set_value("validity_acc_to_today", i);



	
def daily():
	e=frappe.db.get_value("Bank Guarantee",None, "end_date")
	n=frappe.utils.nowdate()
	i=frappe.utils.data.date_diff (e, n)
	doc.validity_acc_to_today=i
	```



hooks.py

```scheduler_events = {
 	"all": [
 		"bg.tasks.all"
 	],
 	"daily": [
 		"bg.tasks.daily"
 	],

 	"hourly": [
 		"bg.tasks.hourly"
 	],
 	"weekly": [
 		"bg.tasks.weekly"
 	],
	
 	"monthly": [
 		"bg.tasks.monthly"
 	],
	"cron": {
        "59 10 * * *": [
            "bg.task.every_day_at_10_59"
        ]
},
}

# Testing

Try

def daily():
	doc=frappe.get_doc("Bank Guarantee", None)
	n = frappe.utils.nowdate()
	i = frappe.utils.data.date_diff (doc.end_date, n)
	doc.validity_acc_to_today=i
    doc.save()

I am guessing Bank Guarantee is a Single DocType

I tried this… but still not getting expected output