给定当前的出生日期和日期,您如何找到一个人的年龄? [英] How do you find a person's age when given the current date and date of birth?
本文介绍了给定当前的出生日期和日期,您如何找到一个人的年龄?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要编写一个程序,在其中输入当前日期和用户的出生日期,并为您提供用户的天数。我已经看过这项工作很多年了,但是几天甚至几个月似乎都没用。我们将不胜感激。
I need to make a program where you enter the current date and the user's date of birth and it gives you the user's age in days. I have seen this work for years, but days and months do not seem to work. Help would be much appreciated.
推荐答案
用户的天数
the user's age in days
您可以使用 TimeSpan.Days
You can use TimeSpan.Days
Dim span As TimeSpan = currentDate - birthDate
Dim days As Int32 = span.Days
例如我的生日:
Dim currentDate = Date.Now
Dim birthDate = New DateTime(1973, 7, 3)
Dim span As TimeSpan = currentDate - birthDate
Dim days As Int32 = span.Days ' => 14870 omg
这篇关于给定当前的出生日期和日期,您如何找到一个人的年龄?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文