Use 12-hour format with AM and PM labels
To bucket data by hour of the day and to display it in a 12-hour format, set the columns to 12-hour clock with AM and PM labels.
Add the datetime column to your query and select Hour of day in the column’s aggregation menu.
Select Run query.
Add a "Formula column" step, select Custom as the formula type, and use the following formula to cast the datetime column as an integer (replace
"Hour of Day: Created At"
with the name of your datetime column).CAST("Hour of Day: Created At" AS integer)
For clarity, we renamed our newly added “Custom formula” column to “Hour” using a "Rename column" step; however, renaming the column is optional.
Add another “Formula column” step, again selecting Custom as the formula type, and use the following
CASE
statement to change the “Hour” column to a 12-hour format with AM and PM labels:CASE WHEN ("Hour" = 0) THEN "12 AM" WHEN "Hour" = 12 THEN ("Hour" || " PM") WHEN "Hour" < 12 THEN ("Hour" || " AM") ELSE (("Hour"-12) || " PM") END
We rename the new “Custom formula” column to “Hour of day” for clarity.
Hide the original datetime column and the “Hour” column from Step 2, then add a "Reorder column" step to move the “Hour of Day” column so it’s the lleftmost column in the result table.
Select the chart type to best represent your data and style it as you see fit!