[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

From timestamps to time difference

Posted on 2011-09-26
1
Medium Priority
?
255 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
anjos earned 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

649 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