![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
![]() |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
|
|
#1
|
|||
|
|||
|
Error al buscar fechas TDateTimePicker a Mysql
Estimados amigos,
Tengo un problemita con la lectura de fechas en C++ con Mysql utilizando TDateTimePicker y ADOQuery. Cuando envio el siguiente código con formato "2018/01/01" me funciona bien pero cuando lo envío en el formato "01/01/2018" (el que usaré), mysql no lo lee y no arroja nada, ejemplo: Código funcional: Código:
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("SELECT cbx_participacion_datos.fecha_ci");
ADOQuery1->SQL->Add("FROM cbx_participacion_datos");
ADOQuery1->SQL->Add("WHERE (cbx_participacion_datos.fecha_ci = :PVALUE1)");
ADOQuery1->Parameters->ParamByName("PVALUE1")->Value = Date.DateString(); // :PVALUE1 = "2018/01/01"
ADOQuery1->Open();
ADOQuery1->First();
Código que no lee Mysql: Código:
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("SELECT cbx_participacion_datos.fecha_ci");
ADOQuery1->SQL->Add("FROM cbx_participacion_datos");
ADOQuery1->SQL->Add("WHERE (cbx_participacion_datos.fecha_ci = :PVALUE1)");
ADOQuery1->Parameters->ParamByName("PVALUE1")->Value = Date.DateString(); // :PVALUE1 = "01/01/2018"
ADOQuery1->Open();
ADOQuery1->First();
Saludos. |
|
#2
|
||||
|
||||
|
Hola.
No uso MySQL pero por lo que pude leer, aparentemente almacena las fechas con el formato YYYY/MM/DD. Entonces pienso que tal vez la función DATE_FORMAT() te pueda ayudar. Por lo que indica el enlace pienso que habría que hacer algo similar a esto: Código:
...
ADOQuery1->SQL->Add("WHERE (DATE_FORMAT(FECHA_CI,"%d/%m/%Y") = :PVALUE1)");
ADOQuery1->SQL->Parameters->ParamByName("PVALUE1")->Value = "01/01/2018"; //(*)
Saludos ![]()
__________________
Daniel Didriksen Guía de estilo - Uso de las etiquetas - La otra guía de estilo .... |
|
#3
|
||||
|
||||
|
Estimado,
Si el campo fecha_ci es de tipo DATE, DATETIME ó TIMESTAMP, puede hacer: Código PHP:
Código PHP:
-
__________________
"constructive mind, destructive thoughts" |
|
#4
|
|||
|
|||
|
Cita:
Código:
[bcc32 Error] Formulario_Principal.cpp(728): E2316 'AsDateTime' is not a member of 'TParameter' Probe el código de ecfisa, no me dio errores pero no me reconocio las fechas, pero buscando por google el DATE_FORMAT() que menciono ecfisa, encontre otra función parecida "FormatDateTime()" y me funciono perfectamente, dejo el código: Código:
ADOQuery1->SQL->Add("WHERE (cbx_participacion_datos.fecha_ci) >= :PVALUE1");
ADOQuery1->Parameters->ParamByName("PVALUE1")->Value = FormatDateTime("yyyy/mm/dd",TDateTimePicker->Date.DateString());
Código:
ADOQuery1->SQL->Add("WHERE (cbx_participacion_datos.fecha_ci) >= :PVALUE1");
ADOQuery1->Parameters->ParamByName("PVALUE1")->Value = FormatDateTime("yyyy/mm/dd hh:mm:ss",TDateTimePicker->Datetime);
|
![]() |
|
|
Temas Similares
|
||||
| Tema | Autor | Foro | Respuestas | Último mensaje |
| Almacenar un TDateTimePicker en MySQL | Gusso | MySQL | 15 | 27-11-2015 22:09:13 |
| busqueda por fecha en mysql con tdatetimepicker | yossi | Varios | 2 | 13-04-2010 02:11:46 |
| Deshabilitar y Habilitar seleccionar fechas de un TDateTimePicker | rgstuamigo | OOP | 3 | 17-01-2009 14:42:47 |
| buscar entre dos fechas | jocey | Varios | 1 | 25-10-2007 21:05:52 |
| Mostrar fechas en lo componentes TDateTimePicker | dec | Trucos | 0 | 30-06-2006 23:12:55 |
|