如何在C#中获得年龄 [英] How to get age in c#

查看:106
本文介绍了如何在C#中获得年龄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据库中有hv雇员表,其中包含雇员的出生日期.如何获取雇员年龄c#?请尽快答复.

i hv employee table in my database where contain the employee birth date.how do get the employee age c#?please reply soon.

推荐答案

有什么努力吗?对于C#或ASP.Net,这确实无关紧要.一种方法是:

Any effort? This really has nothing to with C# or ASP.Net for that matter. One way would be:

int age = new DateTime(DateTime.Now.Subtract(birthday).Ticks).Year-1;



您可以通过使用datediff创建计算列来在表中使用DATEDIFF .
http://msdn.microsoft.com/en-us/library/ms189794.aspx [ ^ ]
您也可以按照 Manas
解决方案1中的说明进行操作 最好的问候
米特瓦里(M.Mitwalli)
Hi ,
You can use DATEDIFF in your Table by creating Computed column with datediff .
http://msdn.microsoft.com/en-us/library/ms189794.aspx[^]
Also you can do it as mention in solution 1 by Manas
Best Regards
M.Mitwalli


这篇关于如何在C#中获得年龄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆