Ir al contenido


Foto

[RESUELTO] date time picker


  • Por favor identifícate para responder
10 respuestas en este tema

#1 root

root

    mister

  • Miembro Platino
  • PipPipPip
  • 529 mensajes
  • LocationMexico D.F:

Escrito 13 julio 2010 - 03:04

Diantres

tengo un query que no da

se los paso a ver que estoy haciendo mal

el problema es que no me esta almacenando las fechas


sql
  1. ZQuery1.SQL.text:= 'insert into convenios(fecha,plazo,periodo,monto,f1,f2,f3,'+
  2.                     'f4,f5,f6,f7,f8,f9,f10,f11,f12,p1,p2,p3,p4,p5,p6,p7,p8,p9,' +
  3.                     'p10,p11,p12) VALUES(now(),"'+ combobox1.text+'","'+
  4.                     combobox2.text + '","' + label1.caption + '",' +
  5.                     datetostr(datetimepicker2.DATE) + ',' + datetostr(datetimepicker3.DATE) + ',' +
  6.                     datetostr(datetimepicker4.DATE) + ',' + datetostr(datetimepicker5.DATE) + ',' +
  7.                     datetostr(datetimepicker6.DATE) + ',' + datetostr(datetimepicker7.DATE) + ',' +
  8.                     datetostr(datetimepicker8.DATE) + ',' + datetostr(datetimepicker9.DATE) + ',' +
  9.                     datetostr(datetimepicker10.DATE) + ',' + datetostr(datetimepicker11.DATE) + ',' +
  10.                     datetostr(datetimepicker12.DATE) + ',' + datetostr(datetimepicker13.DATE) + ',' +
  11.                     edit5.Text + ',' + edit6.Text + ',' + edit7.Text + ',' +
  12.                     edit8.Text + ',' + edit9.Text + ',' + edit10.Text + ',' +
  13.                     edit11.Text + ',' + edit12.Text + ',' + edit13.Text + ',' +
  14.                     edit14.Text + ',' + edit15.Text + ',' + edit16.Text + ') ;' ;



GRACIAS



  • 0

#2 egostar

egostar

    missing my father, I love my mother.

  • Administrador
  • 14.304 mensajes
  • LocationMéxico

Escrito 13 julio 2010 - 03:17

Intenta con esto:



delphi
  1. ZQuery1.sql.text:= 'insert into convenios(fecha,plazo,periodo,monto,f1,f2,f3,'+
  2.                     'f4,f5,f6,f7,f8,f9,f10,f11,f12,p1,p2,p3,p4,p5,p6,p7,p8,p9,' +
  3.                     'p10,p11,p12) VALUES(now(),"'+ combobox1.text+'","'+
  4.                     combobox2.text + '","' + label1.caption + '",' +
  5.                     QuotedStr(datetostr(datetimepicker2.date) )+ ',' + QuotedStr(datetostr(datetimepicker3.date)) + ',' +
  6.                     QuotedStr(datetostr(datetimepicker4.date) )+ ',' + QuotedStr(datetostr(datetimepicker5.date)) + ',' +
  7.                     QuotedStr(datetostr(datetimepicker6.date) )+ ',' + QuotedStr(datetostr(datetimepicker7.date)) + ',' +
  8.                     QuotedStr(datetostr(datetimepicker8.date) )+ ',' + QuotedStr(datetostr(datetimepicker9.date)) + ',' +
  9.                     QuotedStr(datetostr(datetimepicker10.date) )+ ',' +QuotedStr(datetostr(datetimepicker11.date)) + ',' +
  10.                     QuotedStr(datetostr(datetimepicker12.date) )+ ',' + QuotedStr(datetostr(datetimepicker13.date)) + ',' +
  11.                     edit5.Text + ',' + edit6.Text + ',' + edit7.Text + ',' +
  12.                     edit8.Text + ',' + edit9.Text + ',' + edit10.Text + ',' +
  13.                     edit11.Text + ',' + edit12.Text + ',' + edit13.Text + ',' +
  14.                     edit14.Text + ',' + edit15.Text + ',' + edit16.Text + ') ;' ;



Salud OS
  • 0

#3 root

root

    mister

  • Miembro Platino
  • PipPipPip
  • 529 mensajes
  • LocationMexico D.F:

Escrito 13 julio 2010 - 03:26

nop

sigue sin mandar error pero las fechas las guarda como 0000-00-00

pero observando con detenimiento
datetimepicker da las fechas en el formato de dd/mm/aaaa

lo pudo solucionar con el date format ?
  • 0

#4 Caral

Caral

    Advanced Member

  • Moderador
  • PipPipPip
  • 4.266 mensajes
  • LocationCosta Rica

Escrito 13 julio 2010 - 03:34

Hola


delphi
  1. var
  2. Fech: TDate;
  3. begin
  4.   Fech:= Now;
  5.   ZQuery1.sql.text:= 'insert into convenios'+
  6.           '(fecha,plazo,periodo,monto,f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,'+
  7.           ' p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12)'+
  8.   ' VALUES( fec,pla,per,mon,af1,af2,af3,af4,af5,af6,af7,af8,af9,af10,af11,af12,'+
  9.           ' ap1,ap2,ap3,ap4,ap5,ap6,ap7,ap8,ap9,ap10,ap11,ap12 )';
  10.   ZQuery1.Params[0].Value:= Fech;
  11.   ZQuery1.Params[1].Value:= combobox1.text;
  12.   ZQuery1.Params[2].Value:= combobox2.text;
  13.   ZQuery1.Params[3].Value:= label1.caption;
  14.   ZQuery1.Params[4].Value:= datetostr(datetimepicker2.date);
  15.   ZQuery1.Params[5].Value:= datetostr(datetimepicker3.date);
  16.   ZQuery1.Params[6].Value:= datetostr(datetimepicker4.date);
  17.   ZQuery1.Params[7].Value:= datetostr(datetimepicker5.date);
  18.   ZQuery1.Params[8].Value:= datetostr(datetimepicker6.date);
  19.   ZQuery1.Params[9].Value:= datetostr(datetimepicker7.date);
  20.   ZQuery1.Params[10].Value:= datetostr(datetimepicker8.date);
  21.   ZQuery1.Params[11].Value:= datetostr(datetimepicker9.date);
  22.   ZQuery1.Params[12].Value:= datetostr(datetimepicker10.date);
  23.   ZQuery1.Params[13].Value:= datetostr(datetimepicker11.date);
  24.   ZQuery1.Params[14].Value:= datetostr(datetimepicker12.date);
  25.   ZQuery1.Params[15].Value:= datetostr(datetimepicker13.date);
  26.   ZQuery1.Params[16].Value:= edit5.Text;
  27.   ZQuery1.Params[17].Value:= edit6.Text;
  28.   ZQuery1.Params[18].Value:= edit7.Text;
  29.   ZQuery1.Params[19].Value:= edit8.Text;
  30.   ZQuery1.Params[20].Value:= edit9.Text;
  31.   ZQuery1.Params[21].Value:= edit10.Text;
  32.   ZQuery1.Params[22].Value:= edit11.Text;
  33.   ZQuery1.Params[23].Value:= edit12.Text;
  34.   ZQuery1.Params[24].Value:= edit13.Text;
  35.   ZQuery1.Params[25].Value:= edit14.Text;
  36.   ZQuery1.Params[26].Value:= edit15.Text;
  37.   ZQuery1.Params[27].Value:= edit16.Text;
  38.   ZQuery1.ExecSQL;
  39.  
  40. end;


Saludos
  • 0

#5 egostar

egostar

    missing my father, I love my mother.

  • Administrador
  • 14.304 mensajes
  • LocationMéxico

Escrito 13 julio 2010 - 03:36

Amigo Caral

Se le paso un pequeño detalle :p



delphi
  1.   ' VALUES( :fec,:pla,:per,:mon,:af1,:af2,:af3,:af4,:af5,:af6,:af7,:af8,:af9,:af10,:af11,:af12,'+
  2.           ' :ap1,:ap2,:ap3,:ap4,:ap5,:ap6,:ap7,:ap8,:ap9,:ap10,:ap11,:ap12 )';



Salud OS


  • 0

#6 Caral

Caral

    Advanced Member

  • Moderador
  • PipPipPip
  • 4.266 mensajes
  • LocationCosta Rica

Escrito 13 julio 2010 - 04:31

Hola
Dos puntitos de nada.......
Saludos
  • 0

#7 root

root

    mister

  • Miembro Platino
  • PipPipPip
  • 529 mensajes
  • LocationMexico D.F:

Escrito 14 julio 2010 - 08:52

nopo sigue sin guardar las fechas

pero no encuentro como hacer para que date time picker cambie el formato de fecha a

YYYY-MM-DD


  • 0

#8 Caral

Caral

    Advanced Member

  • Moderador
  • PipPipPip
  • 4.266 mensajes
  • LocationCosta Rica

Escrito 14 julio 2010 - 10:08

Hola


delphi
  1.   var
  2. Fech: TDate;
  3. begin
  4.   Fech:= Now;
  5.   ShortDateFormat := 'YYYY-MM-DD';
  6.   ZQuery1.sql.text:= 'insert into convenios'+
  7.           '(fecha,plazo,periodo,monto,f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,'+
  8.           ' p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12)'+
  9.   ' VALUES( :fec,:pla,:per,:mon,:af1,:af2,:af3,:af4,:af5,:af6,:af7,:af8,:af9,:af10,:af11,:af12,'+
  10.           ' :ap1,:ap2,:ap3,:ap4,:ap5,:ap6,:ap7,:ap8,:ap9,:ap10,:ap11,:ap12 )';
  11.   ZQuery1.Params[0].Value:= Fech;
  12.   ZQuery1.Params[1].Value:= combobox1.text;
  13.   ZQuery1.Params[2].Value:= combobox2.text;
  14.   ZQuery1.Params[3].Value:= label1.caption;
  15.   ZQuery1.Params[4].Value:= datetostr(datetimepicker2.date);
  16.   ZQuery1.Params[5].Value:= datetostr(datetimepicker3.date);
  17.   ZQuery1.Params[6].Value:= datetostr(datetimepicker4.date);
  18.   ZQuery1.Params[7].Value:= datetostr(datetimepicker5.date);
  19.   ZQuery1.Params[8].Value:= datetostr(datetimepicker6.date);
  20.   ZQuery1.Params[9].Value:= datetostr(datetimepicker7.date);
  21.   ZQuery1.Params[10].Value:= datetostr(datetimepicker8.date);
  22.   ZQuery1.Params[11].Value:= datetostr(datetimepicker9.date);
  23.   ZQuery1.Params[12].Value:= datetostr(datetimepicker10.date);
  24.   ZQuery1.Params[13].Value:= datetostr(datetimepicker11.date);
  25.   ZQuery1.Params[14].Value:= datetostr(datetimepicker12.date);
  26.   ZQuery1.Params[15].Value:= datetostr(datetimepicker13.date);
  27.   ZQuery1.Params[16].Value:= edit5.Text;
  28.   ZQuery1.Params[17].Value:= edit6.Text;
  29.   ZQuery1.Params[18].Value:= edit7.Text;
  30.   ZQuery1.Params[19].Value:= edit8.Text;
  31.   ZQuery1.Params[20].Value:= edit9.Text;
  32.   ZQuery1.Params[21].Value:= edit10.Text;
  33.   ZQuery1.Params[22].Value:= edit11.Text;
  34.   ZQuery1.Params[23].Value:= edit12.Text;
  35.   ZQuery1.Params[24].Value:= edit13.Text;
  36.   ZQuery1.Params[25].Value:= edit14.Text;
  37.   ZQuery1.Params[26].Value:= edit15.Text;
  38.   ZQuery1.Params[27].Value:= edit16.Text;
  39.   ZQuery1.ExecSQL;
  40.  
  41. end;


Saludos
  • 0

#9 TiammatMX

TiammatMX

    Advanced Member

  • Miembros
  • PipPipPip
  • 1.750 mensajes
  • LocationUniverso Curvo\Vía Láctea\Sistema Solar\Planeta Tierra\América\México\Ciudad de México\Xochimilco\San Gregorio Atlapulco\Home

Escrito 14 julio 2010 - 10:45

nopo sigue sin guardar las fechas

pero no encuentro como hacer para que date time picker cambie el formato de fecha a

YYYY-MM-DD

Te sugiero otro curso de acción.



delphi
  1. sFechaNueva := IntToStr(Year(TuFecha))+'-'+IntToStr(Month(TuFecha))+'-'+IntToStr(Day(TuFecha));



Déjame buscar en la ayuda de FormatDate cómo es que se puede definir el formato que necesitas.


  • 0

#10 TiammatMX

TiammatMX

    Advanced Member

  • Miembros
  • PipPipPip
  • 1.750 mensajes
  • LocationUniverso Curvo\Vía Láctea\Sistema Solar\Planeta Tierra\América\México\Ciudad de México\Xochimilco\San Gregorio Atlapulco\Home

Escrito 14 julio 2010 - 10:48

La ayuda completa de Date-Time Format Strings.

Date/Time format strings control the formatting of dates and times.

Description

Date-Time Format Strings specify the formatting of date-time values (such as TDateTime) when they are converted to strings. Date-Time Format Strings are passed to formatting routines (such as FormatDateTime), and are also used to set certain global variables (such as ShortDateFormat).

Date Time Format Strings are composed from specifiers that represent values to be inserted into the formatted string. Some specifiers (such as "d"), simply format numbers or strings. Other specifiers (such as "/") refer to locale-specific strings from global variables.

In the following table, specifiers are given in lower case. Case is ignored in formats, except for the "am/pm" and "a/p" specifiers.

Specifier    Displays
c    Displays the date using the format given by the ShortDateFormat global variable, followed by the time using the format given by the LongTimeFormat global variable. The time is not displayed if the date-time value indicates midnight precisely.
d    Displays the day as a number without a leading zero (1-31).
dd    Displays the day as a number with a leading zero (01-31).
ddd    Displays the day as an abbreviation (Sun-Sat) using the strings given by the ShortDayNames global variable.
dddd    Displays the day as a full name (Sunday-Saturday) using the strings given by the LongDayNames global variable.
ddddd    Displays the date using the format given by the ShortDateFormat global variable.
dddddd    Displays the date using the format given by the LongDateFormat global variable.
e    (Windows only) Displays the year in the current period/era as a number without a leading zero (Japanese, Korean and Taiwanese locales only).
ee    (Windows only) Displays the year in the current period/era as a number with a leading zero (Japanese, Korean and Taiwanese locales only).
g    (Windows only) Displays the period/era as an abbreviation (Japanese and Taiwanese locales only).
gg    (Windows only) Displays the period/era as a full name. (Japanese and Taiwanese locales only).
m    Displays the month as a number without a leading zero (1-12). If the m specifier immediately follows an h or hh specifier, the minute rather than the month is displayed.
mm    Displays the month as a number with a leading zero (01-12). If the mm specifier immediately follows an h or hh specifier, the minute rather than the month is displayed.
mmm    Displays the month as an abbreviation (Jan-Dec) using the strings given by the ShortMonthNames global variable.
mmmm    Displays the month as a full name (January-December) using the strings given by the LongMonthNames global variable.
yy    Displays the year as a two-digit number (00-99).
yyyy    Displays the year as a four-digit number (0000-9999).
h    Displays the hour without a leading zero (0-23).
hh    Displays the hour with a leading zero (00-23).
n    Displays the minute without a leading zero (0-59).
nn    Displays the minute with a leading zero (00-59).
s    Displays the second without a leading zero (0-59).
ss    Displays the second with a leading zero (00-59).
z    Displays the millisecond without a leading zero (0-999).
zzz    Displays the millisecond with a leading zero (000-999).
t    Displays the time using the format given by the ShortTimeFormat global variable.
tt    Displays the time using the format given by the LongTimeFormat global variable.
am/pm    Uses the 12-hour clock for the preceding h or hh specifier, and displays 'am' for any hour before noon, and 'pm' for any hour after noon. The am/pm specifier can use lower, upper, or mixed case, and the result is displayed accordingly.
a/p    Uses the 12-hour clock for the preceding h or hh specifier, and displays 'a' for any hour before noon, and 'p' for any hour after noon. The a/p specifier can use lower, upper, or mixed case, and the result is displayed accordingly.
ampm    Uses the 12-hour clock for the preceding h or hh specifier, and displays the contents of the TimeAMString global variable for any hour before noon, and the contents of the TimePMString global variable for any hour after noon.
/    Displays the date separator character given by the DateSeparator global variable.
:    Displays the time separator character given by the TimeSeparator global variable.
'xx'/"xx"    Characters enclosed in single or double quotes are displayed as-is, and do not affect formatting.


  • 0

#11 root

root

    mister

  • Miembro Platino
  • PipPipPip
  • 529 mensajes
  • LocationMexico D.F:

Escrito 14 julio 2010 - 04:30



ya quedo entre la idea que me dio caral
y mis super poderes de deduccion ( el modesto )
ya quedo

les paso como kedo


delphi
  1.   ShortDateFormat := 'YYYY-MM-DD';
  2.   ZQuery1.sql.text:= 'insert into convenios'+
  3.           '(fecha,plazo,periodo,monto,f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,'+
  4.           ' p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,trabajador,tfijo,tmovil,email,cartera)'+
  5.   ' VALUES(:fec,:pla,:per,:mon,:af1,:af2,:af3,:af4,:af5,:af6,:af7,:af8,:af9,:af10,:af11,:af12,'+
  6.           ' :ap1,:ap2,:ap3,:ap4,:ap5,:ap6,:ap7,:ap8,:ap9,:ap10,:ap11,:ap12,:traba,:fijo,:movil,:mail,:cartera )';
  7.   ZQuery1.Params[0].Value:= now();
  8.   ZQuery1.Params[1].Value:= combobox1.text;
  9.   ZQuery1.Params[2].Value:= combobox2.text;
  10.   ZQuery1.Params[3].Value:= label1.caption;
  11.   ZQuery1.Params[4].Value:= datetostr(datetimepicker2.date);
  12.   ZQuery1.Params[5].Value:= datetostr(datetimepicker3.date);
  13.   ZQuery1.Params[6].Value:= datetostr(datetimepicker4.date);
  14.   ZQuery1.Params[7].Value:= datetostr(datetimepicker5.date);
  15.   ZQuery1.Params[8].Value:= datetostr(datetimepicker6.date);
  16.   ZQuery1.Params[9].Value:= datetostr(datetimepicker7.date);
  17.   ZQuery1.Params[10].Value:= datetostr(datetimepicker8.date);
  18.   ZQuery1.Params[11].Value:= datetostr(datetimepicker9.date);
  19.   ZQuery1.Params[12].Value:= datetostr(datetimepicker10.date);
  20.   ZQuery1.Params[13].Value:= datetostr(datetimepicker11.date);
  21.   ZQuery1.Params[14].Value:= datetostr(datetimepicker12.date);
  22.   ZQuery1.Params[15].Value:= datetostr(datetimepicker13.date);
  23.   ZQuery1.Params[16].Value:= edit5.Text;
  24.   ZQuery1.Params[17].Value:= edit6.Text;
  25.   ZQuery1.Params[18].Value:= edit7.Text;
  26.   ZQuery1.Params[19].Value:= edit8.Text;
  27.   ZQuery1.Params[20].Value:= edit9.Text;
  28.   ZQuery1.Params[21].Value:= edit10.Text;
  29.   ZQuery1.Params[22].Value:= edit11.Text;
  30.   ZQuery1.Params[23].Value:= edit12.Text;
  31.   ZQuery1.Params[24].Value:= edit13.Text;
  32.   ZQuery1.Params[25].Value:= edit14.Text;
  33.   ZQuery1.Params[26].Value:= edit15.Text;
  34.   ZQuery1.Params[27].Value:= edit16.Text;
  35.  
  36.   ZQuery1.Params[28].Value:= form2.Edit2.Text;
  37.   ZQuery1.Params[29].Value:= form2.Edit1.Text;
  38.   ZQuery1.Params[30].Value:= edit3.Text;
  39.   ZQuery1.Params[31].Value:= edit4.Text;
  40.   ZQuery1.Params[32].Value:= form2.ComboBox2.Text;
  41.  
  42.   ZQuery1.ExecSQL;



  • 0