Count of Related Records

Posted by Paulh0763 on 25-Apr-2016 10:08

I am trying to get a count of the number of related cases for current year on the client record that equal a specific case type and I am using the following:

#CALC_COUNT.R12466576( 1 | createdAt = YEAR && case_type = 5888137)

This only seems to be returning "0" on all records. If I remove the createdAt part it does count the records but for every year, which is not what the client wants.

I am currently on Version but in the process of updating to Version 4.0. 

I thought this was a no brainer. Any help is appreciated. 

Thanks, Paul

All Replies

Posted by Shiva Duriseati on 29-Apr-2016 00:04

Hi Paul,

"createdAt" is stored as "Date/Time" field in MySql database in the format "2016-03-15 15:47:36". This format has to be matched with variable YEAR. 

You can also use rbv_api.selectValue API as follows:

var count=rbv_api.selectValue("SELECT COUNT(1) FROM Cases WHERE createdAt LIKE '2016%' AND naam='india'");


Please let me know if you find any issue.



This thread is closed