DateDiff Calculation

H

Henry Stockbridge

Hi,

I am attempting to calculate the difference in dates between the date
an original email message was received, and the date a reply was
sent. However, this code returns negative numbers, despite the Date1,
and Date2 being in the right sequence.

Dim myItem As Object
Set myItem = Application.ActiveInspector.CurrentItem

DateDiff("d", Format(myItem.ReceivedTime, "Short Date"), Format(Now(),
"Short Date"))

Any thoughts?

Henry
 
H

Henry Stockbridge

It's negative if date2 < date1.

--
Best regards
Michael Bauer - MVP Outlook

  : VBOffice Reporter for Data Analysis & Reporting
  : Outlook Categories? Category Manager Is Your Tool
  : <http://www.vboffice.net/product.html?pub=6&lang=en>

Am Wed, 13 Aug 2008 14:49:55 -0700 (PDT) schrieb Henry Stockbridge:









- Show quoted text -

Michael,

Thanks for your response. I was probably unclear, so I will try
again. Let's say someone sent me a message on 8/1/08. I store that
message in my Inbox. Then, I respond to the sender in a couple days,
say 8/5/08 by opening the message sent on 8/1 and hitting 'Reply.' I
am trying to capture the date the original email was received (8/1)
and find out how many days have elapsed since I replied to the
sender. The DateDiff in this example would return 4 (8/5-8/1.)

Henry
 
M

Michael Bauer [MVP - Outlook]

The funtion doesn't work that way, It's not 8/5 - 8/1, but it's the
difference from 8/5 to 8/1,which is negative.

Simply try it, Datediff returns a negative value if Date1 > Date2.

--
Best regards
Michael Bauer - MVP Outlook

: VBOffice Reporter for Data Analysis & Reporting
: Outlook Categories? Category Manager Is Your Tool
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Thu, 14 Aug 2008 03:20:40 -0700 (PDT) schrieb Henry Stockbridge:
 
H

Henry Stockbridge

The funtion doesn't work that way, It's not 8/5 - 8/1, but it's the
difference  from 8/5 to 8/1,which is negative.

Simply try it, Datediff returns a negative value if Date1 > Date2.

--
Best regards
Michael Bauer - MVP Outlook

  : VBOffice Reporter for Data Analysis & Reporting
  : Outlook Categories? Category Manager Is Your Tool
  : <http://www.vboffice.net/product.html?pub=6&lang=en>

Am Thu, 14 Aug 2008 03:20:40 -0700 (PDT) schrieb Henry Stockbridge:





- Show quoted text -

Thanks, Michael. I'm all set now.
 

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

Similar Threads


Top