Filtrando por fechas en un campo TimeStamp (MariaDB) no incluia el último dia...
C2SQL () no tiene conversión para TimeStamp.
Basado en C2SQL () hice esta función:
Hi...
In MariaDB TimeStamp field, i was need filter between date from two DatePicker
but not included the last day, C2SQL () no have TimeStamp field.
Based in C2SQL () i make function:
Code: Select all
// Función C2SQLTS ()
// Recibe un parámetro Date en formato "dd/mm/aaaa" y otro String "hh:ii:ss"
// Si no se pasa ningun parametro devuelve Fecha y Hora del sistema.
// Si se le pasa solo la Fecha devuelve "23:59:59" como Hora.
// Y lo retorna convertido a string en formato TimeStamp "aaaa-mm-dd hh:ii:ss"
// Usar en lugar de la función C2SQL () sólo en campos TimeStamp
Function C2SQLTS (dpDate,cpTime)
LOCAL cDate := ""
LOCAL cTime := ""
LOCAL cRetu := ""
If Pcount () == 0
cDate := DtoS (Date ())
cTime := Time ()
Else
DO Case
Case Pcount () == 1
cDate := DtoS (dpDate)
cTime := "23:59:59"
Case Pcount () == 2
cDate := DtoS (dpDate)
cTime := AllTrim (cpTime)
EndCase
EndIf
cRetu := "'"+Hb_UsubStr(cDate,1,4)+"-"+Hb_UsubStr(cDate,5,2)+"-"+Hb_UsubStr(cDate,7,2)+" "+cTime+"'"
Return cRetu
Ejemplo:
Code: Select all
LOCAL dDesde := GetProperty ("Proveedores_Entregas" , "DatePicker_Desde" , "Value")
LOCAL dHasta := GetProperty ("Proveedores_Entregas" , "DatePicker_Hasta" , "Value")
cQuery := " SELECT DATE_FORMAT (Fecha,'%d/%m/%Y - %h:%i:%s')"+;
"Fecha, Suc, Cajero, P_Id, Razon, C_Id, Concepto, Tipo, Kilos, Unidades, Remito, Comentario"+;
" FROM Ing_Sucursales WHERE Fecha BETWEEN "+C2SQL (dDesde)+" AND "+C2SQLTS (dHasta)+" AND "+;
"Suc LIKE "+C2SQL (cSucu)+" AND P_Id="+C2SQL (cPId)+" ORDER BY Fecha DESC ;"