How to get day from date in frappe?

Like 2017-12-27
return Wednesday

1 Like

python - How do I get the day of week given a date? - Stack Overflow

edit: further pointers
How to get today date - #2 by BhupeshGupta
How to get today date - #24 by JoEz

@Maheshwari_Bhavesh
Did you know how to do it?
please tell me

@Nada-86

from frappe.utils import get_weekday, getdate
day=get_weekday(getdate(“2023-11-28”))

output: ‘Tuesday’

@bahaou
I want the date by default can I ?

@bahaou

And where I will put this code?

where ever you want

@Hardik_Gadesha check this please
why not become directly?

@Nada-86

Share you code

@Nada-86 Code please

@Hardik_Gadesha for what Client Script or jinja ?

I didn’t write any code for date

@Hardik_Gadesha

frappe.ui.form.on('Employee Clearance Form', {
   var a = new date(frm.doc.date):
   var weekdays=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
   frm.set_value("day",weekdays[a.getDay()])
});

@Nada-86

frappe.ui.form.on('Employee Clearance Form', {
    "date": function(frm) {
       var a = new date(frm.doc.date):
       var weekdays=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
       frm.set_value("day",weekdays[a.getDay()])
    }
});

@Hardik_Gadesha

I replace the : to ; because it shown error , and it did not worked :smiling_face_with_tear:

@Nada-86 date field is present in your doctype ?

@Hardik_Gadesha yes

@Nada-86

frappe.ui.form.on('Employee Clearance Form', {
    "date": function(frm) {
       var a = new Date(frm.doc.date);
       var weekdays=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
       frm.set_value("day",weekdays[a.getDay()]);
    }
});
1 Like

@Hardik_Gadesha
You Are Genius :star_struck:
I hope one day I become like you.