Skip to content

Instantly share code, notes, and snippets.

@ardianta
Created November 11, 2024 02:46
Show Gist options
  • Save ardianta/f55732fb75b4254ac1fbfef4ca751e1e to your computer and use it in GitHub Desktop.
Save ardianta/f55732fb75b4254ac1fbfef4ca751e1e to your computer and use it in GitHub Desktop.
Query to show the most active booking hours
SELECT
HOUR(CONVERT_TZ(`bookingCreatedAt`, '+00:00', '+08:00')) AS jam, -- convert UTC time to local time +08:00
COUNT(*) AS total_booking
FROM
Booking -- table name
WHERE
YEAR(`bookingCreatedAt`) = 2024 AND MONTH(`bookingCreatedAt`) = 10 -- month of year 2024
GROUP BY
jam
ORDER BY
jam LIMIT 100
@ardianta
Copy link
Author

Query Result:
Screenshot 2024-11-11 at 10 47 14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment