Explaination Of Date Interval Function

  • Thread starter Thread starter Steve Crowhurst
  • Start date Start date
S

Steve Crowhurst

I have a field [DOB]and a field [Gender]I want to predict
a retirement date and display that value in a textbox.
Something along these lines: If [Gender] = "M" Then [DOB]
* 65, also [Gender] = "F" Then [DOB] * 60
Now to the second question, which is along the same basic
lines, the field in this case is [StartDate] and the
textbox will display a value three months hence.In a
nutshell can somebody tell how I manipulate dates & times
fields, a few examples would be very welcome. Thank you
all for taking the time and trouble to help.
 
Date and time is a numeric type with 1 meaning 1 day, or 24 hrs. All
arithmetics are valid for Date and Time.
Roughly speaking,
RetirementDate = - ([Gender] = "F") * ([DOB] + 60 * 365 + 15) -
([Gender] = "M") * ([DOB] + 65 * 365 + 16)
ThreeMonthsFromNow = Now() + 92

Pavel
 
There are more accurate ways of doing it.

RetirementDate = IIf([Gender] = "F", _
DateAdd("yyyy",60, [DOB]), DateAdd("yyyy", 65, [DOB]))
ThreeMonthsFromNow = DateAdd("m", 3, Date())

or

RetirementDate = IIf([Gender] = "F", _
DateSerial(Year([DOB]) + 60, Month([DOB]), Day([DOB]), _
DateSerial(Year([DOB])+ 65, Month([DOB]), Day([DOB])
ThreeMonthsFromNow = DateSerial(Year(Date()), Month(Date()) + 3,
Day(Date()))

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Pavel Romashkin said:
Date and time is a numeric type with 1 meaning 1 day, or 24 hrs. All
arithmetics are valid for Date and Time.
Roughly speaking,
RetirementDate = - ([Gender] = "F") * ([DOB] + 60 * 365 + 15) -
([Gender] = "M") * ([DOB] + 65 * 365 + 16)
ThreeMonthsFromNow = Now() + 92

Pavel

Steve said:
I have a field [DOB]and a field [Gender]I want to predict
a retirement date and display that value in a textbox.
Something along these lines: If [Gender] = "M" Then [DOB]
* 65, also [Gender] = "F" Then [DOB] * 60
Now to the second question, which is along the same basic
lines, the field in this case is [StartDate] and the
textbox will display a value three months hence.In a
nutshell can somebody tell how I manipulate dates & times
fields, a few examples would be very welcome. Thank you
all for taking the time and trouble to help.
 
Back
Top