Ver Mensaje Individual
  #5  
Antiguo 30-06-2005
didier didier is offline
Miembro
 
Registrado: jul 2003
Ubicación: Santiago, Chile
Posts: 56
Reputación: 21
didier Va por buen camino
resta de horas

Amigos del club he solucionado el problema de la siguiente manera, quizás no es la mas optima pero para mi problema esta OK, ya que necesito mostrar el día en un campo y la hora en otro aquí mando código por si alguien lo necesitara.

Gracias

Código Delphi [-]
//calcula cantidad de horas
 
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, DateUtils;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    DateTimePicker1: TDateTimePicker;
    DateTimePicker2: TDateTimePicker;
    Label2: TLabel;
    DateTimePicker3: TDateTimePicker;
    DateTimePicker4: TDateTimePicker;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  fecha : string;
  Tfecha1 : TDateTime;
  Tfecha2 : TDateTime;
begin
  fecha := datetostr(DateTimePicker1.Date) + ' ' +
           timetostr(DateTimePicker2.time);
  Label1.Caption := fecha;
  Tfecha1 := strtodatetime(fecha);
  Label2.Caption := datetimetostr(Tfecha1);

  fecha := datetostr(DateTimePicker3.Date) + ' ' +
           timetostr(DateTimePicker4.time);
  Label3.Caption := fecha;
  Tfecha2 := strtodatetime(fecha);
  Label4.Caption := datetimetostr(Tfecha2);

  Label5.Caption :=  inttostr(HoursBetween(tfecha2 , tfecha1));
end;

end.

Última edición por dec fecha: 02-01-2008 a las 17:44:20.
Responder Con Cita