Hi Monks and Monkesses.

Am using Date::Calc in a Booking applic. Clients apply, date gets written etc... (usual stuff) and the booking date gets written in "yyyymmdd hh:mm" format to a flat file db.

Once the Admin confirms the booking, that time/date also gets written in the same format.

I've got a simple "Statistics" box in the Admin's area, and one of the stats I'd like to display is the average time taken between booking and confirmation, not on an individual booking basis, but for the whole lot of bookings.

I hope I've simplified things (for the server) by writing only relavent data to a "totals-to-date" file (again flat file db - one line/booking) upon the Admin "Confirming" the booking.

That data includes the booking_date|confirmation_date|time_diff|... etc. The time_diff data is in the format "days:hours:mins" (forget the secs! :-/ )

The only thing I can think of at the moment is to use Date::Calc to convert (somehow?!?) this data for each record into seconds, add up the seconds for each booking, then divide by the total number of confirmed bookings and then back again into days, hours & minutes once all data has been read, and then to display it in the Statistics box.

Is this the "right" way? (right/wrong - easy/difficult - all relative!!!) Does Date::Calc (v5.3) have a function to do this sort of thing? If I have to go the "convert to seconds" route, would this put an un-necessary load on the server ("totals-to-date" db file should not exceed 1000 records - but you never know!!!) ?

Any opinions obviously appreciated. By the sheer amount of time/date related stuff I've come across, manipulating times/dates appears to be something of a black art.

Kind regards from Andorra.
Richard.


In reply to Calculating the average time taken.. by meetn2veg

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.