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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateDiff helf in MS Access 2

Status
Not open for further replies.

herd

Technical User
Jun 23, 2003
46
US
If I have two date fields (Date1 and Date2) how would I get a date3 that's between date1 and date2?
I’ve tried

DateAdd("d",(DateDiff("d",Date1,Date2)/2),Date1)

Date3 = Date1 + (Date2 - Date1) / 2

When I tried both of these codes into my date3 field I get a return of #Name?............what am I doing wrong?

Thanks Gary
 
Try this.........

Dim D1 As Long
D1 = date2 - date1
NewDate = date1 + (D1 / 2)


 
Convert to Days and then back to date.

General approach.
Dim diffDays as double, beginDays as double, tempDays as double, Date3 as Date
diffDays = DateDiff("d",Date1,Date2)
beginDays = Cdbl(Date1)
tempDays = diffDays / 2
beginDays = beginDays + tempDays
Date3 = Cdate(beginDays)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top