Solved

From timestamps to time difference

Posted on 2011-09-26
1
215 Views
Last Modified: 2012-05-12
Hi there,

I have a history list which refers to any request that has been made on a certain website.
All request timestamps are in column A.
The value in column B is the user who made that request.
  history.xls

My goal is :
- for each user, get the connection duration by day, week or month

We consider that if there is 2 (or more) consecutive requests in less than 10 minutes, we can add the time difference as "connection time".
i.e.:
2011-07-04 10:16:20	326
2011-07-04 10:17:17	326

Open in new window

=> connection time = 0:57mn

Thank you for your suggestions !

Eric
0
Comment
Question by:eirikur
1 Comment
 
LVL 3

Accepted Solution

by:
anjos earned 500 total points
ID: 36599946
ie you can use this to get a timespan:
public TimeSpan dateTimeDifference(string d1, string d2)
        {
            DateTime startDate, endDate;

            if (DateTime.TryParse(d1, out startDate) && DateTime.TryParse(d2, out endDate))
                if (DateTime.Compare(startDate, endDate) < 0)
                {
                    TimeSpan span = endDate.Subtract(startDate);
                    return span;
                }

            return TimeSpan.Zero;
        }

And this to get a time difference:
public string makeTimeString(TimeSpan t)
        {
            string H = "", M = "";

            if (t.Hours < 10)
                H = "0";
            if (t.Minutes < 10)
                M = "0";

            H += t.Hours.ToString();
            M += t.Minutes.ToString();

            return H + ":" + M;
        }
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now