Delphi日期函数与日期加减.pdf

  1. 1、本文档共19页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多

.word可编辑.

Delphi日期函数、日期加减

Delphi里有现成的函数可以实现日期加减,是在DateUtils单元里的。

functionIncYear(constAValue:TDateTime;

constANumberOfYears:Integer=1):TDateTime;

//functionIncMonthisinSysUtils

functionIncWeek(constAValue:TDateTime;

constANumberOfWeeks:Integer=1):TDateTime;

functionIncDay(constAValue:TDateTime;

constANumberOfDays:Integer=1):TDateTime;

functionIncHour(constAValue:TDateTime;

constANumberOfHours:Int64=1):TDateTime;

functionIncMinute(constAValue:TDateTime;

constANumberOfMinutes:Int64=1):TDateTime;

functionIncSecond(constAValue:TDateTime;

constANumberOfSeconds:Int64=1):TDateTime;

functionIncMilliSecond(constAValue:TDateTime;

constANumberOfMilliSeconds:Int64=1):TDateTime;

Day开头的函数

Unit

.专业.专注.

.word可编辑.

DateUtils

functionDateOf(constAvalue:TDateTime):TDateTime;

描述

使用DateOf函数用来把一个TDateTime类型的变量转变成一个

只带有日期的TDateTime类型变量。

例如:

showmessage(DateTimetostr(dateof(now())));

你得到的是2003/03/19

而showmessage(DateTimetostr((now())));

得到的是2003/03/1910:50:49

●functionDateTimeToStr(DateTime:TDateTime):string;

描述

DateTimeToString函数将TDateTime类型的参数DateTime转换成一个

字符串,使用给定的全局变量ShortDateFormat的格式,时间部分按照

给定的全局变量LongTimeFormat的格式。

其中DateTime为零的部分将不会显示出来。

.专业.专注.

.word可编辑.

例如:

ShortDateFormat:=yyyymmdd;

showmessage(DateTimetostr((now())));

你将得到:2003031910:50:49

●procedureDateTimeToString(varResult:string;constFormat:string;DateTime:

TDateTime);

描述:

DateTimeToString方法将TDateTime类型的参数DateTime按照由参数Format提供的格

转化成字符串,并保存在Result中。

对于Format的格式类型,请看Date-Timeformatstrings的帮助。

例如:

DateTimeToString(result,yyyymmdd,now());

那么result的结果为:2003031910:50:49

●procedureDateTimeToSystemTime(DateTime:TDateTime;varSystemTime:

TSystemTime);

文档评论(0)

秋天 + 关注
实名认证
内容提供者

三十年河东,三十年河西,莫欺少年穷。

1亿VIP精品文档

相关文档