Formatting timestamps and dates
Timestamps can be confusing when viewed as text (e.g., '2020-06-02 23:57:12.120174 UTC'
), especially in a report format. Ensuring that your reports are easy to understand can be a factor in determining how your results are used.
This exercise is part of the course
Introduction to BigQuery
Exercise instructions
- Add the date formatting for the column
order_purchase_timestamp
in the'MM/DD/YY'
format using the%D
option.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
-- Fill in the query to find the three days with the most orders
SELECT
-- First, add the date formatting for dates
FORMAT_TIMESTAMP(___, ___) AS order_date,
order_id
FROM
ecommerce.ecomm_order_details
LIMIT 3;