Use 12-hour format with AM and PM labels

Still need help?

The Atlassian Community is here for you.

Ask the community

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.

  1. Add the datetime column to your query and select Hour of day in the column’s aggregation menu.

  2. Select Run query.

  3. 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)

  4. For clarity, we renamed our newly added “Custom formula” column to “Hour” using a "Rename column" step; however, renaming the column is optional.

  5. 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

  6. We rename the new “Custom formula” column to “Hour of day” for clarity.

  7. 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.

  8. Select the chart type to best represent your data and style it as you see fit!

Last modified on Sep 10, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.