Page 1 of 1

Deleting particular Case in Entry App

Posted: June 30th, 2020, 11:48 am
by Yass
Dear Cspro Team,

I find some data with a date reference i would like to delete at the Interviewer level tablet after updating their program, in this way i wrote this function but it seems it not deleting cases created on or before 26th June 2020. The intend again is to delete cases created on or a particular date on Interviewers Tablet.

Please is my code right ?

Code: Select all

function traindate()

forcase coreMkt_dict where dateOfInterview <= 26062020  & reg=13  do

		delcase(coreMkt_dict );
		
	endfor;
	
 end;

Re: Deleting particular Case in Entry App

Posted: June 30th, 2020, 1:35 pm
by Gregory Martin
The loop and delete calls seem okay. I would be worried about how you're using the date of interview though. It's generally best to use dates in the format YYYYMMDD if you want to do comparisons. Your code, for example, would not delete a case from 27 May because 27052020 is not <= 26062020.

You will likely want to convert your DDMMYYYY date into a format where you can do the comparison. Something like this:
forcase coreMkt_dict where reg = 13 do

    numeric
day = int(dateOfInterview / 1000000);
   
numeric month = int(dateOfInterview / 10000) % 100;

   
if month < 6 or ( month = 6 and day <= 26 ) then
        delcase
(coreMkt_dict);
   
endif;

endfor;

Re: Deleting particular Case in Entry App

Posted: June 30th, 2020, 3:09 pm
by Yass
Thanks Greg for the help and additional teaching !!