meetn2veg has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Calculating the average time taken..
by liz (Monsignor) on Aug 24, 2003 at 15:15 UTC | |
|
Re: Calculating the average time taken..
by CombatSquirrel (Hermit) on Aug 24, 2003 at 15:34 UTC |