Forum Discussion
split or extract?
- 1 year ago
mamatea1218 If format is constant then extracting first 11 characters is good because Extracting a fixed number of characters is generally faster and less error-prone and It is straightforward if the date part is always exactly 11 characters long.
If there is any possibility of variation in the format, splitting by delimiter might be a safer choice.
Hi mamatea1218
When working with a datetime column in Power BI that has values like "2025-07-07 at 12:40", both splitting the column using the delimiter "at" and extracting the first 11 characters to isolate the date portion are technically valid. However, using "extract" (e.g., extract the first 10 or 11 characters for the date) is generally considered better practice in formal scenarios or exams for a few key reasons. First, extracting is more robust and efficient—it avoids relying on the exact placement or spacing of a delimiter like "at", which may vary or cause errors if the format slightly changes (e.g., extra spaces). Second, extract operations are cleaner and easier to maintain, especially when you know the date is always fixed in length and at the start of the string. Third, exams and official best practices emphasize predictability and performance, and extract is usually faster and more direct than a split-then-trim operation. That said, splitting by "at" is very intuitive and useful when you want to separate both the date and time into two columns, especially if the delimiter is consistent. In summary, "extract" is preferred in exams and standardized scenarios for its simplicity, stability, and alignment with best practices, even though "split" is perfectly acceptable in hands-on situations.