Calculating the time in days between two dates

S

Sidney

Hello

I have two fields with dates on my database that I need calculate between:

Field 1 - Date of Referral
Field 2 - Date of Discharge

I need the results to be displayed on a form.

Can somebody help?

Many Thanks
Sidney
 
L

Linq Adams via AccessMonster.com

Something like this, where TreatmentDays is the field holding the difference :


Private Sub DischargeDate_AfterUpdate()
If Not IsNull(Me.ReferralDate) Then
Me.TreatmentDays = DateDiff("d", Me.ReferralDate, Me.DischargeDate)
Else
MsgBox "You Must Have a Referral Date Entered!"
ReferralDate.SetFocus
End If
End Sub

Private Sub ReferralDate_AfterUpdate()
If Not IsNull(Me.DischargeDate) Then
Me.TreatmentDays = DateDiff("d", Me.ReferralDate, Me.DischargeDate)
End If
End Sub

This assumes ReferralDate will be entered first, but allows for the event
that the user enters a DischargeDate before entering the ReferralDate first.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top