Filter by dates between 2 dates in frappe.call

I need to filter all attendance between 2 dates variables but filter works on filters individually not get dates between

var start=someDate
var end =someDate
frappe.call({
   method:"frappe.client.get_list",
   args :{
   doctype:'Attendance',
filters:{'attendance_date':['Between',start,'and',end]
        }},
    	"callback": function(response) {}
})
1 Like

I had same issue and solve it
follow this steps

1 Like

I appreciate your response and thank you >>
I found its easier to use list in filter:
filters:[['attendance_date','>=',from_date] , ['attendance_date','<=',to_date]

1 Like

where do you put this string?

inside frappe.call() filters:

	frappe.call({
                    method:"frappe.client.get_list",
                    args :{
                    doctype:'Attendance',
                   
                    filters:[['attendance_date','>=',from_date] ,
                    ['attendance_date','<=',to_date]
  
                    ]},
                    	"callback": function(response) {
                    	    console.log(response.message)
                            
}
})

You can use ‘between’ for a date range.

frappe.call({
    method: "frappe.client.get_list",
    args: {
        doctype: "Daily Power Usage",
        filters: [
            ['unit_name', "=", unit_name],
            ['room_name', "=", room_name],
            ['power_usage_date', "between", [power_usage_date_from, power_usage_date_to]],
        ],
        fields: ['name', 'unit_name', 'room_name', 'power_usage_date', 'power_usage_kwh'],
        order_by: 'power_usage_date'
    },
    callback: function (r) {
        console.log(r);
    },

});
2 Likes

Also this can be accepted answer, Thanks for your effort

1 Like