DEA-C02 Data Transformation Practice Question
A data engineer is working with a table that has a column `order_date` of type DATE. The engineer needs to create a new column that contains the year and month in the format 'YYYY-MM' (e.g., '2023-01') for each order. Which Snowflake function should be used to produce this formatted string?
⚠ Common exam trap
The trap here is assuming that DATE_TRUNC or EXTRACT can directly produce a formatted string, when they return date or numeric types.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
TO_CHAR(order_date, 'YYYY-MM')
TO_CHAR with a format string is the correct function to convert a date into a custom string format. It directly produces the 'YYYY-MM' representation, including leading zeros for months. Other options either return a date, invalid syntax, or lack proper formatting.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
DATE_TRUNC('month', order_date)
Why it's wrong here
DATE_TRUNC truncates a date to the specified precision, returning a DATE. For 'month', it returns the first day of the month, not a formatted string. The result would be a DATE, not a string in 'YYYY-MM' format. Additional formatting would still be needed, so this does not directly produce the required output.
- ✗
CONCAT(YEAR(order_date), '-', MONTH(order_date))
Why it's wrong here
This approach uses YEAR and MONTH functions to extract numeric parts and concatenates them with a hyphen. However, MONTH returns a number without leading zero, so January would be '1' instead of '01'. The result would not match the 'YYYY-MM' format for months 1-9. It would require additional padding logic.
- ✗
EXTRACT(YEAR_MONTH FROM order_date)
Why it's wrong here
EXTRACT with YEAR_MONTH is not valid Snowflake syntax. Snowflake supports EXTRACT with individual fields like YEAR, MONTH, DAY, but not a combined YEAR_MONTH. Even if it did, it would return a numeric value, not a formatted string. Therefore, this does not meet the requirement.
- ✓
TO_CHAR(order_date, 'YYYY-MM')
Why this is correct
TO_CHAR converts a date or timestamp to a string using the specified format. Using 'YYYY-MM' returns the year and month in the desired format. This is the standard function for formatting dates in Snowflake and is the simplest way to achieve the required transformation.
Visual reference
About these practice questions
One of 229 original DEA-C02 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Snowflake exam blueprint
This DEA-C02 practice question is part of Courseiva's free Snowflake certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DEA-C02 exam.