Ver Mensaje Individual
  #1  
Antiguo 01-05-2012
Avatar de microbiano
microbiano microbiano is offline
Miembro
 
Registrado: sep 2008
Ubicación: Mexico D.F
Posts: 349
Reputación: 16
microbiano Va por buen camino
Smile Ayuda con Saber si una fecha es menor a la fecha del Servidor

bien resulta que quiero comparar la fecha que tengo registrada en el sistema conla fecha del servidor, y si es menor entonces modifique una columna de pago tardio, pero no logro ahcer que funcione. lo hago de la isguiente manera.

obtengo la fecha del Servidor asi.

WFechaServidor:TDate;

Código Delphi [-]
procedure TFmodulo.FechaServidor;
var I:Integer;
begin
 with Fmodulo.QryTemp do
  begin
   close;
   sql.Clear;
   SQL.Add('SELECT CONVERT(VARCHAR(10), GETDATE(), 103) AS [Fecha]');
   try
    Open;
    if (not Eof) then
     begin
      wfechaservidor:=StrToDate(FieldByname('Fecha').AsString);//aqui pongo la fecha del servidor
      DecodeDate(Wfechaservidor,anio,Mes,Dia);
      if Anio<>0 then
       begin
        wanioString:=IntToStr(Anio);
       end;
     end;
   except
    on E:EOleException do
     begin
       MessageDlg(Format('Error: %s    Codigo: %d', [E.Message, E.ErrorCode]), mtError, [mbOK], 0);
     end;      
   end;
  end;
end;

y entonces despues genero 12 recibos en un modulo de cuentas por cobrar y para poder modificar la situacion de cada recibo lo hago de la siguiente manera.

Código Delphi [-]
function tfrmrecibos.CargaMeses(IdContrato:string):string;
var wStatus:string;
    WfechaRegistro:TDate;
begin
 with fmodulo.QryTemp do
  begin
   Close;
   sql.Clear;
   sql.Add('select * from sap_prerecibos');
   sql.Add('where nocontrato=:Pnocontrato and fechaPago is null');
   Parameters.ParamByName('Pnocontrato').Value:=Idcontrato;
   try
    Open;
    while (not Eof) do
    begin
     cbb_1.Items.Add(FieldByname('concepto').AsString);
     WfechaRegistro:=(FieldByName('fechafinpago').AsDateTime);
     if Trunc(WfechaRegistro) < trunc(Fmodulo.WFechaServidor) then //aqui es donde hago la validacion pero no funciona me cambia la columna de todos los registros aqui valida la fecha de fin de pago que son 12 recibos de enero a diciembre y fechafin de pago es el 30 de cada mes
      wStatus:='S';
      begin
       with Fmodulo. QryTemporal do
        begin
         SQL.Clear;
         SQL.Add('update sap_prerecibos set interes=status');
         SQL.Add('where nocontrato=contrato and FechaPago is null');
         Parameters.ParamByName('Pcontrato').Value:=Idcontrato;
         Parameters.ParamByName('Pstatus').Value:=Trim(wStatus);
         ExecSQL;
        end;
      end;
     Next;
    end;
    
   except
    on e:eoleException do
     begin

     end;  
   end;
  end;   
end;

alguna sugerencia? de antemano muchas gracias
Responder Con Cita