delphi DecodeDate:从一个TDateTime变量中提取年、月、日数值  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi DecodeDate:从一个TDateTime变量中提取年、月、日数值


声明:

procedure DecodeDate ( const SourceDate : TDateTime; out Year, Month, Day : Word ) ;

描述:DecodeDate过程从一个给定的TDateTime类型SourceDate参数中提取相应的年、月、日的值。

它将数值保存在输出型变量Year、Month、Day中。

var
myDate : TDateTime;
myYear, myMonth, myDay : Word;
begin
// 设myDate变量值勤为2009年12月29日
myDate := StrToDate('2009-12-29');

// 再加上一个月
myDate := IncMonth(myDate);

// 得到了什么?
DecodeDate(myDate, myYear, myMonth, myDay);
ShowMessage('myDate now = '+DateToStr(myDate));
ShowMessage('myDay = '+IntToStr(myDay));
ShowMessage('myMonth = '+IntToStr(myMonth));
ShowMessage('myYear = '+IntToStr(myYear));
end;

程序运行结果:

myDate now = 2010-1-29

myDay = 29

myMonth = 1

myYear = 2010

推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.057726144790649 seconds