Substring to get a year from date


#1

I need to get the counts by birth year.
I need to extract year from the birthdate and get the counts group by year.
please help me solve this issue.

MyType.evaluate({
projection: “count(), (substring(birthDate,0,4))”,
group: “substring(birthDate,0,4)”,
offset: i * 10000,
limit: 10000,
forceDbEngineEval: true,
filter: “substring(birthDate,0,4) !=null”
});


#2

When you execute that evaluate, what response are you getting?


#3

@matt thank you for looking into this. I was able to solve this by following:

It is working for me.

   MyType.evaluate({
        projection: "count(), year(birthDate)",
        group: "year(birthDate)",
        offset: i * 10000,
        limit: 10000,
        forceDbEngineEval: true,
        filter: "year(birthDate) !=null"
    }); 

thanks again !