Error on client script sql function

I’m having error when trying to filter based on year as codes below:

frappe.call({
    method: 'frappe.client.get_list',
    args: {
        'parent': 'Expense Claim',
        'doctype': 'Expense Claim Detail',
        'filters': [
            ['expense_type','in',['Medical','Additional Medical']],
            ['owner','=',frm.doc.owner],
            ['year(expense_year)','=',frappe.datetime.str_to_obj(frm.doc.posting_date).getFullYear()],
        ],
        'fields':['expense_type','amount'],
    },
    callback: function(r) {
        console.log(r);
    }
});

This just gives me error as image below:

May I know what is the correct way to filter based on year on particular field?

Hi @muhdazwa,

Please check the references.

Another reference:

I hope this helps.

Thank You!

Hi @NCP ,

Actually I’m trying to use sql function to extract year from field expense_date which is a full date but it seems Frappe doesn’t like sql function usage in the filters.

Client side, maybe it’s not possible but server side it’s possible.

Please check it: Database API

Please read the whole documentation.

I hope this helps.

Thank You!