Help! SQL Average Querie...

2 replies
Found 22nd Feb 2010
Hi,

I am trying to find the average amount of days spent at a hotel using two fields, dateofarrival and dateofdeparture. The table name is HotelDetails.

Anyone know how to take the average between two dates?

Thanks!

  1. Misc
Groups
  1. Misc
2 Comments

From comments in ]here, this might work... haven't used sql in years tho!

SELECT CAST(AVG(CAST(HotelDetails.dateofdeparture- HotelDetails.dateofarrival AS float)) AS datetime)
FROM HotelDetails

EDIT:
or you might want something like this?

SELECT hotelname, CAST(AVG(CAST(HotelDetails.dateofdeparture- HotelDetails.dateofarrival AS float)) AS datetime)
FROM HotelDetails
GROUP BY hotelname

Original Poster

Ambdon;7916937

From comments in ]here, this might work... haven't used sql in years … From comments in ]here, this might work... haven't used sql in years tho!SELECT CAST(AVG(CAST(HotelDetails.dateofdeparture- HotelDetails.dateofarrival AS float)) AS datetime)FROM HotelDetails



Thanks
Post a comment
Avatar
@
    Text
    Top Discussions
    1. Add one, leave one game54415463
    2. Without giving away your age, name three things that remind you of when you…52114
    3. 5 Letter Scrabble Game52522882
    4. One4all gift cards can only be converted to Amazon codes until MIDNIGHT TON…33

    See more discussions