Greetings fellow Monks!
I have an MySql table, which records the entry and exit time of a customer in the system using a timestamp, which is automatically generated.
What I am confused with right now is that I have to find the average time that a customer spends in the system.
Since a timestamp includes both the date and time, I need to be able to subtract the two values (one from the timestamp of entry and the other of exit) and convert this into time.
Please assist me in this. I have been trying to get a proper alogrithm for this but am not being successful!
Hoping for a helpful reply
Agyeya Gupta
Update
Perhaps if i was not clear above, there are two records for each customer. One contains the timestamp for entry, and some other processing details. And the second record contains the timestamp for exit.
The timestamp is in <yyyymmddhhmmss>format where the hour is in the 24 hour clock format
The average time formula should be
(The total time spent by the customers in the system)/(Total number of customers)

In reply to MySql Timestamps by Agyeya

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.