For an appointment i'm creating a vaccine app and it saves ppl SSN so like 199411111111 and i need to get the ppl between certain age group so i can see how many doses they have got the problem is the last 4 because the are diffrent from person to person. So i need to search on the first 8 numbers but i dont know how.
This is how i find the right age group.
cal.add(Calendar.YEAR, -intLow);
Date low = cal.getTime();
cal.add(Calendar.YEAR, -intHigh);
Date high = cal.getTime();
String sdflow = sdf.format(low);
String sdfhigh = sdf.format(high);
int test1 = Integer.parseInt(sdflow);
int test2 =Integer.parseInt(sdfhigh);
This is how i tried to search for it with a query
Query Qage=ref.orderBy("SSN").startAt(test1).endAt(test2);
this doesn't work beacause the numbers that i start at and end is way samaller than the SSN so is there a way to just search for the first 8 numbers and not the last 4?
CodePudding user response:
If you want to sort on the high bits of a number, you can do:
ref.orderBy("SSN").startAt(12340000).endAt(12349999);
CodePudding user response:
You Can do - ref.orderBy("SSN").startAt(12340000).endAt(12349999);