By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,813 Members | 2,269 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,813 IT Pros & Developers. It's quick & easy.

datediff function

P: 53
i dont knot the code to calculate how old some one is in years and days.

i have to make the code where i can eneter some ones birthdate and then calculate the years and days diffrent from the date that is now.



Thank you,
David Moore
Sep 7 '07 #1
Share this Question
Share on Google+
7 Replies


YarrOfDoom
Expert 100+
P: 1,247
Could you maybe specify where you want to use the code for, because I remember having to create the same code for school once. Nothing personal, just rules :P

Yarr Of Doom
Sep 7 '07 #2

P: 53
Could you maybe specify where you want to use the code for, because I remember having to create the same code for school once. Nothing personal, just rules :P

Yarr Of Doom


we have to let the person input thier name b-day and, thier height, so it needs to be up next to all of that. SOrry i am brand new at this, so im sorry if i am confusing!!
Sep 7 '07 #3

YarrOfDoom
Expert 100+
P: 1,247
I'm sorry cdm2883, but with "Nothing personal, just rules" I meant that the forums aren't here to have your homework done for you. But there's one tip I will give you (altough you probably found that yourself already): use date-variables.


Yarr Of Doom
Sep 7 '07 #4

kadghar
Expert 100+
P: 1,295
i dont knot the code to calculate how old some one is in years and days.

i have to make the code where i can eneter some ones birthdate and then calculate the years and days diffrent from the date that is now.



Thank you,
David Moore
sure define a date variable:
dim d as date
where the birthdate is set
then just make a rest and place it wherever you want, lets say a message box:

msgbox("You are " & date - d & " days old.")

Hope that helps
Sep 7 '07 #5

QVeen72
Expert 100+
P: 1,445
Hi,

Use DateDiff Function :

Expand|Select|Wrap|Line Numbers
  1. MsgBox DateDiff("D",CDate(txtDate), Date)
  2.  
If u want diff in Months, u can use "m" instaed of "D"
and for years "Y"

Regards
Veena
Sep 8 '07 #6

P: 53
Hi,

Use DateDiff Function :

Expand|Select|Wrap|Line Numbers
  1. MsgBox DateDiff("D",CDate(txtDate), Date)
  2.  
If u want diff in Months, u can use "m" instaed of "D"
and for years "Y"

Regards
Veena


Thank you, but i am writing my code in a Console App. how would i do it without a Msgbox?!

Thanks
Sep 9 '07 #7

QVeen72
Expert 100+
P: 1,445
Hi,

Instead of Msgbox, Assign the result of "DateDiff" to a Numeric Variable..

Regards
Veena
Sep 10 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.