How many years?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi!

In main form I have two textboxes, txt1 and txt2, with dates.

The 3td textbox has in ControlSource:
=([txt1]-[txt2])

Return a number.
How is possible to return a number of years between them, please?

Thnaks in advence.
an
 
Hi!

In main form I have two textboxes, txt1 and txt2, with dates.

The 3td textbox has in ControlSource:
=([txt1]-[txt2])

Return a number.
How is possible to return a number of years between them, please?

Thnaks in advence.
an

=([txt1]-[txt2]) will return the number of days between 2 dates.

=DateDiff("yyyy",[Txt1],[Txt2])

will return the number of years between 2 dates. Note: That will
return the number of year 'bounderies' that the date crosses, i.e.
DateDiff("yyyy",#12/31/2006#,#1/1/2007# ) returns 1 year, even though
it's just 1 day.

If you need a more accurate actual difference, I suggest you look at
"A More Complete DateDiff Function" at
http://www.accessmvp.com/djsteele/Diff2Dates.html

which will return the difference in years, months, and days.

Regardless of which function is suitable, the calculated value should
not be stored in any table. Anytime you need the difference between
the two dates, re-calculate it, as above.
 
Thanks, F.

My dificult is to fixed permanently date in field AgeOnEvent date.
an

fredg said:
Hi!

In main form I have two textboxes, txt1 and txt2, with dates.

The 3td textbox has in ControlSource:
=([txt1]-[txt2])

Return a number.
How is possible to return a number of years between them, please?

Thnaks in advence.
an

=([txt1]-[txt2]) will return the number of days between 2 dates.

=DateDiff("yyyy",[Txt1],[Txt2])

will return the number of years between 2 dates. Note: That will
return the number of year 'bounderies' that the date crosses, i.e.
DateDiff("yyyy",#12/31/2006#,#1/1/2007# ) returns 1 year, even though
it's just 1 day.

If you need a more accurate actual difference, I suggest you look at
"A More Complete DateDiff Function" at
http://www.accessmvp.com/djsteele/Diff2Dates.html

which will return the difference in years, months, and days.

Regardless of which function is suitable, the calculated value should
not be stored in any table. Anytime you need the difference between
the two dates, re-calculate it, as above.
 
Back
Top