
Select con BETWEEN que no funciona.
Publicado por Bladimir (8 intervenciones) el 11/10/2016 03:09:06
Hola a todos. Tengo una tabla llamada relaciones donde se almacenan una serie de datos que incluyen la fecha de insercion del dato en un texto con formato YYYY-MM-DD. La sentencia que extrae la informacion funciona solo cuando extraigo datos insertados solo hoy, es decir la fecha actual y solo un dia; pero cuando la fecha es una fecha pasada, por ejemplo, 2016-09-19 no lo hace. El codigo que uso es el siguiente:
No consigo el error. Mucho agradezco la ayuda prestada.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
protected void verpxcaroni() {
// TODO Auto-generated method stub
String ini = mDateDisplay.getText().toString();
String fin = mDateEndDisplay.getText().toString();
TextView titulotb = (TextView)this.findViewById(R.id.titulotb);
titulotb.setText("RELACION HCC LAPSO " + ini + " al " + fin );
TableLayout table2 = (TableLayout)this.findViewById(R.id.tableLayout);
TableRow row2 = (TableRow)LayoutInflater.from(this).inflate(R.layout.cabecera_dos, null);
table2.addView(row2);
baseDatos = openOrCreateDatabase(nombreBD, MODE_WORLD_WRITEABLE, null);
Cursor cur = baseDatos.rawQuery("SELECT nombre, apellidos, cedula, edad, fecha, concepto, monto FROM relaciones WHERE fecha BETWEEN '" + ini + "' AND '" + fin + "' AND centro='HCC'", null);
for(int i = 0; i < cur.getCount(); i++){
TableLayout table = (TableLayout)this.findViewById(R.id.tableLayout);
while (cur.moveToNext()){
String nombre = cur.getString(0);
String apellido = cur.getString(1);
String cedula= cur.getString(2);
String age= cur.getString(3);
String fecha= cur.getString(4);
String concepto= cur.getString(5);
String monto= cur.getString(6);
TableRow row = (TableRow)LayoutInflater.from(this).inflate(R.layout.fila, null);
((TextView)row.findViewById(R.id.textView1)).setText(nombre);
((TextView)row.findViewById(R.id.textView2)).setText(apellido);
((TextView)row.findViewById(R.id.textView3)).setText(cedula);
((TextView)row.findViewById(R.id.textView4)).setText(age);
((TextView)row.findViewById(R.id.textView5)).setText(fecha);
((TextView)row.findViewById(R.id.textView6)).setText(concepto);
((TextView)row.findViewById(R.id.textView7)).setText(monto);
table.addView(row);
}
table.requestLayout();
ini="";
fin="";
}
}
Valora esta pregunta


0