delphi日期函数、日期加减

delphi日期函数、日期加减

ID:13881160

大小:39.50 KB

页数:9页

时间:2018-07-24

delphi日期函数、日期加减_第1页
delphi日期函数、日期加减_第2页
delphi日期函数、日期加减_第3页
delphi日期函数、日期加减_第4页
delphi日期函数、日期加减_第5页
资源描述:

《delphi日期函数、日期加减》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、delphi日期函数、日期加减2008-02-2909:12Delphi里有现成的函数可以实现日期加减,是在DateUtils单元里的。functionIncYear(constAValue:TDateTime;constANumberOfYears:Integer=1):TDateTime;//functionIncMonthisinSysUtilsfunctionIncWeek(constAValue:TDateTime;constANumberOfWeeks:Integer=1):TDateTime;functionIncDay(constAValue:TD

2、ateTime;constANumberOfDays:Integer=1):TDateTime;functionIncHour(constAValue:TDateTime;constANumberOfHours:Int64=1):TDateTime;functionIncMinute(constAValue:TDateTime;constANumberOfMinutes:Int64=1):TDateTime;functionIncSecond(constAValue:TDateTime;constANumberOfSeconds:Int64=1):TDateTim

3、e;functionIncMilliSecond(constAValue:TDateTime;constANumberOfMilliSeconds:Int64=1):TDateTime;Day开头的函数●UnitDateUtilsfunctionDateOf(constAvalue:TDateTime):TDateTime;描述使用DateOf函数用来把一个TDateTime类型的变量转变成一个只带有日期的TDateTime类型变量。例如:showmessage(DateTimetostr(dateof(now())));你得到的是2003/03/19而showm

4、essage(DateTimetostr((now())));得到的是2003/03/1910:50:49●functionDateTimeToStr(DateTime:TDateTime):string;描述DateTimeToString函数将TDateTime类型的参数DateTime转换成一个字符串,使用给定的全局变量ShortDateFormat的格式,时间部分按照给定的全局变量LongTimeFormat的格式。其中DateTime为零的部分将不会显示出来。例如:ShortDateFormat:=’yyyymmdd’;showmessage(DateT

5、imetostr((now())));你将得到:2003031910:50:49●procedureDateTimeToString(varResult:string;constFormat:string;DateTime:TDateTime);描述:DateTimeToString方法将TDateTime类型的参数DateTime按照由参数Format提供的格式转化成字符串,并保存在Result中。对于Format的格式类型,请看Date-Timeformatstrings的帮助。例如:DateTimeToString(result,’yyyymmdd’,now

6、());那么result的结果为:2003031910:50:49●procedureDateTimeToSystemTime(DateTime:TDateTime;varSystemTime:TSystemTime);描述:有时为了调用API函数来使用系统时间,你可以使用DateTimeToSystemTime方法,来将一个TDateTime类型的时间变量转换成一个TSystemTime类型的系统时间。●functionDateTimeToUnix(constAvalue:TDateTime):Int64;描述:使用DateTimeToUnix函数来将一个TDa

7、teTime型时间变量转换成一个相应的Unix格式的日期和时间。Unixdate-and-timevaluesareencodedasthenumberofsecondsthathaveelapsedsincemidnightatthestartofJanuary1,1970.●functionDateToStr(Date:TDateTime):string;描述:使用DateToStr函数能得到TDateTime日期时间类型的日期部分。日期的转换格式依赖于全局变量ShortDateFormat。●functionDayOf(constAvalue:TDateTi

8、me):W

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。