Help! SQL Average Querie... - HotUKDeals
We use cookie files to improve site functionality and personalisation. By continuing to use HUKD, you accept our cookie and privacy policy.
Get the HUKD app free at Google Play

Search Error

An error occurred when searching, please try again!

Login / Sign UpSubmit

Help! SQL Average Querie...

SAVE4IT Avatar
6y, 11m agoPosted 6 years, 11 months ago
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!
SAVE4IT Avatar
6y, 11m agoPosted 6 years, 11 months ago
Options

All Comments

(2) Jump to unreadPost a comment
Comments/page:
1 Like #1
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
#2
Ambdon
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

You don't need an account to leave a comment. Just enter your email address. We'll keep it private.

...OR log in with your social account

...OR comment using your social account

Thanks for your comment! Keep it up!
We just need to have a quick look and it will be live soon.
The community is happy to hear your opinion! Keep contributing!