如何实现对时间的加减乘除 有没有函数可以用 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 var time1,time2,time3:TDatetime; h,m,s:integer;begin time3:=time1-time2; decodetime(time3,h,m,s); result:=h*3600+m*60+s;end; 渔在帮助中查 IncHour看seealso 刚才是减现在 加decodedate(date,year,month,day); date:=encodedate(year+5, month, day); Step.1 TDateTime -> 整数Step.2 整数 加、减、乘、除Step.3 整数 -> TDateTime//主要是看你要用什么为单位//参考如下函数DecodeTime();DecodeDate();EncodeTime();EncodeDate(); TDateTime=Double当然可以加、减、乘、除可是你想得到什么呢?日期乘日期是什么?这些诶函数可能会有用:function YearsBetween(const ANow, AThen: TDateTime): Integer;function MonthsBetween(const ANow, AThen: TDateTime): Integer;function WeeksBetween(const ANow, AThen: TDateTime): Integer;function DaysBetween(const ANow, AThen: TDateTime): Integer;function HoursBetween(const ANow, AThen: TDateTime): Int64;function MinutesBetween(const ANow, AThen: TDateTime): Int64;function SecondsBetween(const ANow, AThen: TDateTime): Int64;function MilliSecondsBetween(const ANow, AThen: TDateTime): Int64;{ Increment/decrement datetime fields }function IncYear(const AValue: TDateTime; const ANumberOfYears: Integer = 1): TDateTime;// function IncMonth is in SysUtilsfunction IncWeek(const AValue: TDateTime; const ANumberOfWeeks: Integer = 1): TDateTime;function IncDay(const AValue: TDateTime; const ANumberOfDays: Integer = 1): TDateTime;function IncHour(const AValue: TDateTime; const ANumberOfHours: Int64 = 1): TDateTime;function IncMinute(const AValue: TDateTime; const ANumberOfMinutes: Int64 = 1): TDateTime;function IncSecond(const AValue: TDateTime; const ANumberOfSeconds: Int64 = 1): TDateTime;function IncMilliSecond(const AValue: TDateTime; const ANumberOfMilliSeconds: Int64 = 1): TDateTime; 如果你用Delphi做,那很费劲,Oracle里有个Interval函数可以做这个,但值能做100年那的加减操作。如果你是Delphi6,那请参考DateUtils单元文件,有不少现成的函数呢:function IncYear(const AValue: TDateTime; const ANumberOfYears: Integer = 1): TDateTime;// function IncMonth is in SysUtilsfunction IncWeek(const AValue: TDateTime; const ANumberOfWeeks: Integer = 1): TDateTime;function IncDay(const AValue: TDateTime; const ANumberOfDays: Integer = 1): TDateTime;function IncHour(const AValue: TDateTime; const ANumberOfHours: Int64 = 1): TDateTime;function IncMinute(const AValue: TDateTime; const ANumberOfMinutes: Int64 = 1): TDateTime;function IncSecond(const AValue: TDateTime; const ANumberOfSeconds: Int64 = 1): TDateTime;function IncMilliSecond(const AValue: TDateTime; const ANumberOfMilliSeconds: Int64 = 1): TDateTime;================================================================CSDN 论坛助手 Ver 1.0 B0402提供下载。 改进了很多,功能完备!★ 浏览帖子速度极快![建议系统使用ie5.5以上]。 ★ 多种帖子实现界面。 ★ 保存帖子到本地[html格式]★ 监视您关注帖子的回复更新。★ 可以直接发贴、回复帖子★ 采用XML接口,可以一次性显示4页帖子,同时支持自定义每次显示帖子数量。可以浏览历史记录! ★ 支持在线检测程序升级情况,可及时获得程序更新的信息。★★ 签名 ● 可以在您的每个帖子的后面自动加上一个自己设计的签名哟。Http://www.ChinaOK.net/csdn/csdn.zipHttp://www.ChinaOK.net/csdn/csdn.rarHttp://www.ChinaOK.net/csdn/csdn.exe [自解压] delphi 获取浏览器URL地址时出现异常 请教个tcp/ip的端口的问题 两 个DBComboBoxEh 怎么实现 两级下拉 请问如何读取某程序中某寄存器的值? 谁有wwdbgrid控件,急[email protected] 在MDI程序里如何把子窗体的标题栏怎么设成无的呀?(急!SOS) 创建ODBC 别名出错,请教! 关于网页的问题!请关注!! listbox中的循环问题 怎样对计算字段排序?20分 coolslob兄请注意,问你一个'CSDN搜索助手'里的问题,希望不吝赐教! 如何取的网站的数据接口?
time1,time2,time3:TDatetime;
h,m,s:integer;
begin
time3:=time1-time2;
decodetime(time3,h,m,s);
result:=h*3600+m*60+s;
end;
现在 加
decodedate(date,year,month,day);
date:=encodedate(year+5, month, day);
Step.2 整数 加、减、乘、除
Step.3 整数 -> TDateTime//主要是看你要用什么为单位
//参考如下函数
DecodeTime();
DecodeDate();
EncodeTime();
EncodeDate();
当然可以加、减、乘、除
可是你想得到什么呢?
日期乘日期是什么?
这些诶函数可能会有用:
function YearsBetween(const ANow, AThen: TDateTime): Integer;
function MonthsBetween(const ANow, AThen: TDateTime): Integer;
function WeeksBetween(const ANow, AThen: TDateTime): Integer;
function DaysBetween(const ANow, AThen: TDateTime): Integer;
function HoursBetween(const ANow, AThen: TDateTime): Int64;
function MinutesBetween(const ANow, AThen: TDateTime): Int64;
function SecondsBetween(const ANow, AThen: TDateTime): Int64;
function MilliSecondsBetween(const ANow, AThen: TDateTime): Int64;{ Increment/decrement datetime fields }function IncYear(const AValue: TDateTime;
const ANumberOfYears: Integer = 1): TDateTime;
// function IncMonth is in SysUtils
function IncWeek(const AValue: TDateTime;
const ANumberOfWeeks: Integer = 1): TDateTime;
function IncDay(const AValue: TDateTime;
const ANumberOfDays: Integer = 1): TDateTime;
function IncHour(const AValue: TDateTime;
const ANumberOfHours: Int64 = 1): TDateTime;
function IncMinute(const AValue: TDateTime;
const ANumberOfMinutes: Int64 = 1): TDateTime;
function IncSecond(const AValue: TDateTime;
const ANumberOfSeconds: Int64 = 1): TDateTime;
function IncMilliSecond(const AValue: TDateTime;
const ANumberOfMilliSeconds: Int64 = 1): TDateTime;
function IncYear(const AValue: TDateTime;
const ANumberOfYears: Integer = 1): TDateTime;
// function IncMonth is in SysUtils
function IncWeek(const AValue: TDateTime;
const ANumberOfWeeks: Integer = 1): TDateTime;
function IncDay(const AValue: TDateTime;
const ANumberOfDays: Integer = 1): TDateTime;
function IncHour(const AValue: TDateTime;
const ANumberOfHours: Int64 = 1): TDateTime;
function IncMinute(const AValue: TDateTime;
const ANumberOfMinutes: Int64 = 1): TDateTime;
function IncSecond(const AValue: TDateTime;
const ANumberOfSeconds: Int64 = 1): TDateTime;
function IncMilliSecond(const AValue: TDateTime;
const ANumberOfMilliSeconds: Int64 = 1): TDateTime;
================================================================CSDN 论坛助手 Ver 1.0 B0402提供下载。 改进了很多,功能完备!★ 浏览帖子速度极快![建议系统使用ie5.5以上]。 ★ 多种帖子实现界面。
★ 保存帖子到本地[html格式]★ 监视您关注帖子的回复更新。
★ 可以直接发贴、回复帖子★ 采用XML接口,可以一次性显示4页帖子,同时支持自定义每次显示帖子数量。可以浏览历史记录!
★ 支持在线检测程序升级情况,可及时获得程序更新的信息。★★ 签名 ●
可以在您的每个帖子的后面自动加上一个自己设计的签名哟。Http://www.ChinaOK.net/csdn/csdn.zip
Http://www.ChinaOK.net/csdn/csdn.rar
Http://www.ChinaOK.net/csdn/csdn.exe [自解压]