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

How to get midpoint between two DateTime fields

Status
Not open for further replies.

ziggs

Technical User
Sep 21, 2000
195
US
I'm trying to write a report that will give me the midpoint between two datetime fields. How can this be done?

Example #1:

if the first datetime field is 04/10/02 09:00:00AM and second is 04/10/02 10:00:00AM, then I want the midpoint to be 04/10/02 09:30:00AM

Example #2:

if the first datetime field is 04/09/02 11:00:00PM and second is 04/10/02 03:00:00AM, then I want the midpoint to be 04/10/02 01:00:00AM

I'm missing something that might be simple. TIA
 
Dateadd("d",datediff("d",{date1},{date2})/2,{date1}) should give you the midpoint in whole days.

Datediff("d",{Date1},{Date2}) will return the number of whole days between two dates. My formula above simply divides this by 2 and adds it to the first date with the Dateadd() function.

Please post again if this does not work for you. Software Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
Thanks for the input. However, this unfortunately does not give me the result that I'm looking for. The formula that you provided only works on the day. What I'm looking for is the exactly mid point by the minute. I do appreciate your effort.
 
Look up the help files for Datediff() and Dateadd(). There are several more arguments other than "d", which give you several options. If those do not help you, please post again. Software Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top