
Answer-first summary for fast verification
Answer: SELECT order_id, date_format(order_timestamp, ‘dd-MM-YYYY‘) as order_date FROM orders;
The `date_format()` function converts a timestamp to a string in the specified format. The correct format for the desired output 'dd-MM-YYYY' uses 'dd' for the day of the month, 'MM' for the month of the year, and 'YYYY' for the year, all separated by hyphens. The correct query is: `SELECT order_id, date_format(order_timestamp, ‘dd-MM-YYYY‘) as order_date FROM orders;`. For more details on datetime patterns, refer to the Datetime patterns documentation.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
A data engineer needs to extract the date part from the order_timestamp column in the orders Delta table, formatting it as '31-12-2022', where the first two digits represent the day of the month, followed by the month of the year, and finally the year itself, all separated by hyphens. Which query should the data engineer use to achieve this?
A
SELECT order_id, date_format(order_timestamp, ‘MM-DD-YYYY‘) as order_date FROM orders;
B
SELECT order_id, date_format(order_timestamp, ‘dd-MM-YYYY‘) as order_date FROM orders;
C
SELECT order_id, date_fmt(order_timestamp, ‘dd-MM-YYYY‘) as order_date FROM orders;
D
SELECT order_id, date_format(order_timestamp, ‘DD-MM-YYYY‘) as order_date FROM orders;
E
SELECT order_id, date_format(order_timestamp, ‘MM-dd-YYYY‘) as order_date FROM orders;