Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating date from scroll bar input

Status
Not open for further replies.

skippypaul

Programmer
Nov 20, 2002
3
0
0
US
I have got a form set up where a person's date of birth is input using three scroll bars (one date, one month and one year) and need to use this input to calculate a persons age.

Having difficulty converting the input(s) to a form that can be used in a "DateDiff" statement.

I only seem to have people been either 0 years or 104 years old.
 
Use dateserial to correct your date in VB way, the use your datediff

e.g.

myDate = dateSerail(varyear, varmonth, varday)
myAge = dateDiff("yyyy", date, myDate)

goodluck....

[ponder]KrK

 

Well the first problem that I can see with doing something like this how you use the datediff function. Are you trying to get the difference in years, then in months, then days? Because
[tt]
MsgBox DateDiff("yyyy", "01/01/1970", Date)
[/tt]
will work while
[tt]
MsgBox DateDiff("yyyy", "11/01/1970", Date)
[/tt]
will return the wrong result that you are looking for.

A little more info may be helpful

Good Luck

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top