C
cooksc
I have a date that appears to be a string ( exp. 3/4/2009 ) and I want to
query the date using a form. Simply, I have a begin date and a end date that
I want to find. The date field is not acting like a date field. The date is
being generating from:
Function PEdate(hrdt, fortyfivedn, ninetydn, sixmth, plusyrdn) As Date
Dim numyrs, yr, yr1, yr2, yr3
If Not IsDate(hrdt) Then
PEdate = Now()
Else
If Now() - hrdt < 365 Then
If Not IsDate(fortyfivedn) Then
PEdate = hrdt + 45
DateValue (PEdate)
ElseIf Not IsDate(ninetydn) Then
PEdate = hrdt + 90
DateValue (PEdate)
ElseIf Not IsDate(sixmth) Then
PEdate = hrdt + 180
DateValue (PEdate)
ElseIf Not IsDate(plusyrdn) Then
PEdate = hrdt + 365
DateValue (PEdate)
ElseIf IsDate(plusyrdn) Then
PEdate = hrdt + 730
DateValue (PEdate)
End If
Else
If Not IsDate(plusyrdn) Then 'no date entered
numyrs = DateDiff("yyyy", hrdt, Now())
PEdate = DateAdd("yyyy", numyrs, hrdt)
' PEdate = hrdt + numyrs * 365.25
DateValue (PEdate)
Else
' date there now figure out what year it was and add one
yr = DatePart("yyyy", plusyrdn)
yr1 = DatePart("yyyy", hrdt)
yr2 = ((yr - yr1) + 1)
yr3 = ((yr - yr1) + 2)
PEdate = DateAdd("yyyy", yr2, hrdt)
If PEdate - plusyrdn < 90 Then
PEdate = DateAdd("yyyy", yr3, hrdt)
'numyrs = DateDiff("yyyy", HRDT, Now())
'PEdate = DateAdd("yyyy", numyrs + 1, HRDT)
' PEdate = hrdt + ((numyrs + 1) * 365.25)
DateValue (PEdate)
End If
End If
End If
End If
End Function
I am using this code from another datebase and need to know how modify it or
modify a query so the date is truely a date.
Thank you for any help you can give me.
Steve
query the date using a form. Simply, I have a begin date and a end date that
I want to find. The date field is not acting like a date field. The date is
being generating from:
Function PEdate(hrdt, fortyfivedn, ninetydn, sixmth, plusyrdn) As Date
Dim numyrs, yr, yr1, yr2, yr3
If Not IsDate(hrdt) Then
PEdate = Now()
Else
If Now() - hrdt < 365 Then
If Not IsDate(fortyfivedn) Then
PEdate = hrdt + 45
DateValue (PEdate)
ElseIf Not IsDate(ninetydn) Then
PEdate = hrdt + 90
DateValue (PEdate)
ElseIf Not IsDate(sixmth) Then
PEdate = hrdt + 180
DateValue (PEdate)
ElseIf Not IsDate(plusyrdn) Then
PEdate = hrdt + 365
DateValue (PEdate)
ElseIf IsDate(plusyrdn) Then
PEdate = hrdt + 730
DateValue (PEdate)
End If
Else
If Not IsDate(plusyrdn) Then 'no date entered
numyrs = DateDiff("yyyy", hrdt, Now())
PEdate = DateAdd("yyyy", numyrs, hrdt)
' PEdate = hrdt + numyrs * 365.25
DateValue (PEdate)
Else
' date there now figure out what year it was and add one
yr = DatePart("yyyy", plusyrdn)
yr1 = DatePart("yyyy", hrdt)
yr2 = ((yr - yr1) + 1)
yr3 = ((yr - yr1) + 2)
PEdate = DateAdd("yyyy", yr2, hrdt)
If PEdate - plusyrdn < 90 Then
PEdate = DateAdd("yyyy", yr3, hrdt)
'numyrs = DateDiff("yyyy", HRDT, Now())
'PEdate = DateAdd("yyyy", numyrs + 1, HRDT)
' PEdate = hrdt + ((numyrs + 1) * 365.25)
DateValue (PEdate)
End If
End If
End If
End If
End Function
I am using this code from another datebase and need to know how modify it or
modify a query so the date is truely a date.
Thank you for any help you can give me.
Steve