先分解日期 var Year, Month, Day: Word Year2, Month2, Day2: Word begin DecodeDate(Start_Date;Year, Month, Day); DecodeDate(End_Date;Year2, Month2, Day); if Year-Year>5 if Moneth2>Monethn showmessage('超过日期') end;
uses DateUtils;...
if FormatDateTime('yyyy-mm-dd',IncMonth(start_time,time))>FormatDateTime('yyyy-mm-dd',Date) then begin ShowMessage('过期'); end;//时间日期也可以直接比较。
TDateTime 实际上是 Double(双精度)型,所以两个时间可以直接相减,减出来的结果就是中间的间隔。整数部分为天数,小数部分乘以24就是小时数,再乘60就是分钟数......假设你的5个月的概念为 150 天if Now - start_time>150 then ShowMessage('超时了!');Now函数在SysUtils单元中的定义的,返回当前日期 + 时间
if DaysBetween(start_time,now) div 30 >=5 then ShowMessage('超时了!');也可以這么寫:if DaysBetween(start_time,now) >=150 then ShowMessage('超时了!');
请问;
如何计算 此用户已经超出有效期?很急,望大虾们指教!!
var Year, Month, Day: Word
Year2, Month2, Day2: Word
begin
DecodeDate(Start_Date;Year, Month, Day);
DecodeDate(End_Date;Year2, Month2, Day);
if Year-Year>5
if Moneth2>Monethn
showmessage('超过日期')
end;
DateUtils;...
if FormatDateTime('yyyy-mm-dd',IncMonth(start_time,time))>FormatDateTime('yyyy-mm-dd',Date) then
begin
ShowMessage('过期');
end;//时间日期也可以直接比较。