Ver Mensaje Individual
  #4  
Antiguo 23-08-2012
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 38
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola rufo.
Cita:
es decir yo almaceno en un campo la fecha escogida del objeto Datetimepicker
De este texto yo había interpretado que lo tomabas de un TDateTimePicker de allí mi pregunta, por que si es de tipo entero:
Código Delphi [-]
  ParamByName('mes').AsInteger := MonthOf(DateTimePicker1.Date);

Si es string sin formato :
Código Delphi [-]
  ParamByName('mes').AsString := IntToStr(MonthOf(DateTimePicker1.Date));

Si es string con formato a dos caracteres:
Código Delphi [-]
  ParamByName('mes').AsString := StringOfChar('0', 2-Length(IntToStr(MonthOf(DateTimePicker1.Date)))) +
   IntToStr(MonthOf(DateTimePicker1.Date));
En los tres ejemplos anteriores debe estar incluida la unidad DateUtils.


Ahora si la fecha es tomada de un ComboBox y los items (meses) están en órden cronológico, para string formato a dos caracteres:
Código Delphi [-]
 with ComboBox1 do
   if ItemIndex <> -1 then
      ParamByName('mes').AsString := StringOfChar('0',2-Length(IntToStr(ItemIndex+1))) + IntToStr(ItemIndex+1);

Sin formato:
Código Delphi [-]
 with ComboBox1 do
   if ItemIndex <> -1 then
      ParamByName('mes').AsString := IntToStr(ItemIndex+1);

Saludos.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita