Home > Back-end >  Delphi is used DBedit access database date time, how to compare their difference and system time
Delphi is used DBedit access database date time, how to compare their difference and system time

Time:09-19

Delphi using DBedit date type in access database, how to obtain difference compared with the system time days? The great god ask counsel wow

CodePudding user response:

The former title, the database related tables, open:

[code=dellphi]
Var D: TDateTime;
L: integer;
The begin
D:=ClientDataSet1 FieldByName (' time '). AsDateTime;
.///D:=ADOQuery1 FieldByName (' time '). AsDateTime;
L:=Trunc (Now - D);
If L> 0 then ShowMessage (' has' + IntToStr (L) + 'day! ')
The else ShowMessage (' worse '+ IntToStr (L) +' day! ');
end;
[/code]

CodePudding user response:

The former title, the database related tables, open:

 
Var D: TDateTime;
L: integer;
The begin
D:=ClientDataSet1 FieldByName (' time '). AsDateTime;
.///D:=ADOQuery1 FieldByName (' time '). AsDateTime;
L:=Trunc (Now - D);
If L> 0 then ShowMessage (' has' + IntToStr (L) + 'day! ')
The else ShowMessage (' worse '+ IntToStr (L) +' day! ');
end;

CodePudding user response:

MinutesBetween, bring their own function

CodePudding user response:

 
USES DateUtils;
DaysBetween (Now (), date1)

CodePudding user response:

refer to the second floor lyhoo163 response:
former title, the database related tables, open:

 
Var D: TDateTime;
L: integer;
The begin
D:=ClientDataSet1 FieldByName (' time '). AsDateTime;
.///D:=ADOQuery1 FieldByName (' time '). AsDateTime;
L:=Trunc (Now - D);
If L> 0 then ShowMessage (' has' + IntToStr (L) + 'day! ')
The else ShowMessage (' worse '+ IntToStr (L) +' day! ');
end;


Myself is such use, convenient to remind, the future or expired,

CodePudding user response:

DaysBetween (Now (), date1)
Only difference between them for a few days, can't distinguish, expiration,

CodePudding user response:

Subtracting the integer trunc (now - date1)
  • Related