用DELPHI的什么函数能得到两个日期之间年数(用于取人员的年龄)?

wwypw 2002-02-02 12:26:26
用DELPHI的什么函数能得到两个日期之间年数(用于取人员的年龄)?
如:
已知一时间值为STRING'1970-12-12'
机器系统时间为'2002-02-02'
得到年龄为:32

谢谢!!!
...全文
325 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wwypw 2002-02-02
  • 打赏
  • 举报
回复
谢谢各位,我刚学DELPHI
能不能举个例子?
dancemaple 2002-02-02
  • 打赏
  • 举报
回复
我照chechy老大说的查到的帮助如下:

YearsBetween function

Returns the approximate number of years between two specified TDateTime values.

Unit

DateUtils

Category

date/time routines

function YearsBetween(const ANow, AThen: TDateTime): Integer;

Description

Call YearsBetween to obtain the difference, in years, between two TDateTime values. Because years are not all the same length (e.g. leap years), YearsBetween returns an approximation based on an assumption of 365.25 days per year. Fractional years are not counted. Thus, for example, YearsBetween reports the difference between Jan 1 and Dec 31 as 0 on non-leap years and 1 on leap years.
liang_z 2002-02-02
  • 打赏
  • 举报
回复
YearsBetween ?
定义在什么地方 ?
我为什么没有见过这个函数 ?
抱朴守拙 2002-02-02
  • 打赏
  • 举报
回复
function YearsBetween(const ANow, AThen: TDateTime): Integer;
liang_z 2002-02-02
  • 打赏
  • 举报
回复
(t1-t2)div 365
我想这个不用太精确吧,差个一两天谁知道啊!

TO:chechy
老大的肝肝好了?
chechy 2002-02-02
  • 打赏
  • 举报
回复
function YearsBetween(const ANow, AThen: TDateTime): Integer;
zng 2002-02-02
  • 打赏
  • 举报
回复
用一个存储过程可以解决。(用MSSQL SERVER)
liang_z 2002-02-02
  • 打赏
  • 举报
回复
不会是6.0吧?

830

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧