主页C++ Builder 资料C++ Builder 参考手册System 日期和时间DecodeDate
C++ Builder 串口控件
C++ Builder 编程技巧
C++ Builder 操作指南
C++ Builder 参考手册
基础知识
cfloat 浮点数
cmath 数学函数
cstdlib 标准库函数
System 字符串
System 日期和时间
 • TDate
 • TTime
 • TDateTime
 • TDateTimeBase
 • Now
 • UnixToDateTime
 • DateTimeToUnix
 • DateTimeToStr
 • DateToStr
 • DecodeDate
 • DecodeTime
 • DecodeDateTime
 • FormatDateTime
 • StrToDate
 • StrToDateDef
 • StrToDateTime
 • StrToDateTimeDef
 • StrToTime
 • StrToTimeDef
 • TimeToStr
System.Math.hpp 数学函数
其他数据类型
VCL 基础类
VCL 应用程序
Pictures 图片
Graphics 绘图
Additional 控件
System 控件
A ~ Z 字母顺序排列的目录
网友留言/技术支持
DecodeDate - 从日期时间里面分解出来年、月、日

函数原型:

void __fastcall DecodeDate(const TDateTime DateTime, Word &Year, Word &Month, Word &Day);

头文件:

#include <System.SysUtils.hpp> (XE2 之后) #include <SysUtils.hpp> (XE 之前)

参数:

DateTime: TDateTime 类型的日期时间;
Year: 返回从参数 DateTime 日期时间分解出来的年,1 ~ 9999;
Month: 返回从参数 DateTime 日期时间分解出来的月,1 ~ 12;
Day: 返回从参数 DateTime 日期时间分解出来的日,1 ~ 31。

返回值:

无。解析出来的数据通过参数返回。

 

例:获取当前系统时间的年、月、日

TDateTime dt = Now();
WORD y, m, d;
DecodeDate(dt, y, m, d);
Label1->Caption = String().sprintf(L"%d 年 %d 月 %d 日", y, m, d);

运行结果:

2017 年 6 月 30 日
◤上一页:DateToStr下一页:DecodeTime

C++ 爱好者 -- Victor Chen 的个人网站 www.cppfans.com 辽ICP备11016859号