Power Query Date.ToRecord: Step-by-Step Guide
In this article
Date.ToRecord takes a single date value and returns a record whose fields are that date split into its parts: Year, Month, Day, Quarter, DayOfWeek and more. You call it from a custom column or a step in the M code editor, for example Date.ToRecord(#date(2026, 12, 5)), and you get a record you can then expand into separate columns. Nothing needs installing: the function ships with Power Query in Excel, Power BI Desktop and Power Query Online. You only need a column of values already recognised as dates, or a date literal you type yourself.
What You'll Need
- Power Query available in your tool of choice: Excel (Data > Get & Transform Data), Power BI Desktop (Transform Data), or Power Query Online. Menu names vary slightly by version, platform and region.
- A table with at least one column typed as Date (its icon shows a small calendar, and the column header shows a date type rather than "ABC" or "123").
- Basic familiarity with the Power Query Editor window and where the formula bar is. You can do everything here without writing full queries by hand.
Step-by-Step
- Load or create the query. In Excel, select your table and choose Data > Get & Transform Data > From Table/Range. In Power BI Desktop, choose Home > Transform Data to open the editor on an existing query.
- Confirm the column is a date. Select the column, then look at the data type icon in the column header or the Data Type dropdown on the Home tab. If it says Text or Any, choose Date from the dropdown. Date.ToRecord needs a real date value; a text string like "05/12/2026" will throw an error.
- Add a custom column. Go to Add Column > Custom Column. In the dialog, give it a name such as DateParts and enter this formula, substituting your own column name:
= Date.ToRecord([Order Date])
Click OK. The new column shows the word Record in each cell, and you can click that word to preview the fields inside. - Expand the record into columns. With the new column selected, use the small expand icon in its header (two arrows pointing apart), or right-click the header and choose Expand. Tick the fields you want: Year, Month, Day, Quarter, DayOfWeek, DayOfYear, WeekOfYear, MonthName, DayName and so on. Untick "Use original column name as prefix" if you prefer clean headers, then click OK. Each ticked field becomes its own column.
- Set the data types on the new columns. Power Query often leaves expanded record fields as Any. Set Year, Month, Day, Quarter and DayOfYear to Whole Number, and MonthName and DayName to Text. Leave the original date column alone so you still have a proper date for sorting and date-based visuals.
- Check the M code. Click View > Formula Bar if it is hidden, then select the last step. You should see something like
Table.ExpandRecordColumn(..., "DateParts", {"Year", "Month", "Day"}, ...). This is what makes the query reproducible when it refreshes. - Test refresh and load. Choose Home > Close & Load (Excel) or Close & Apply (Power BI). Add or change a date in the source, refresh, and confirm the split columns update. Sort the original date column ascending and check that a row on a month boundary, such as 31 January into 1 February, has the expected Month and Day values.
If you would rather work in code, you can add the same step manually in the Advanced Editor. Build the record column with Table.AddColumn(Source, "DateParts", each Date.ToRecord([Order Date]), type record) and then expand it. That approach is convenient when you want to add and expand in one pass, but the dialog route is safer because it writes correct syntax for you.
Common Mistakes
- Feeding it text. The most frequent error: the column is typed as Text, so
Date.ToRecordfails with something like "We cannot convert the value to type Date." Change the type to Date first with the locale set correctly, so day/month order is interpreted as you intend. - Calling it on a table or a list. Date.ToRecord takes one date value. If you have a whole column, wrap the call in a custom column so it runs row by row. For a list of dates, use List.Transform.
- Expecting the password or other unusual fields. The record only contains the date parts listed in the expand dialog. There is no time-of-day field; a DateTime column must be converted to Date first, which discards the time.
- Sorting by the name fields. MonthName and DayName are text, so they sort alphabetically (April before January). Sort by Month and Day numbers instead, or add a sort-order column.
- Forgetting that expanding replaces or duplicates columns. Retyping the expanded columns every refresh is unnecessary if types were set after expansion, but if you later add fields you must re-expand or add another expand step.
- Assuming it works on a date literal typed as text in the formula.
Date.ToRecord("2026-12-05")is not the same as a date literal. Use#date(2026, 12, 5)or reference a column.
Tips
- Use the record version when you need several date parts at once. It is one step and one column to expand, which keeps the Applied Steps list easy to read compared with adding six separate Date.Year, Date.Month and Date.Day custom columns.
- Keep the original date column. Charts, slicers and date tables need a genuine date or DateTime type, not separate numbers.
- For fiscal years, Month and Quarter are not enough. Add a custom column with an offset, for example
Date.Year(Date.AddMonths([Order Date], 6))for a July start. - Quarter returns 1 to 4. If your report needs labels such as "Q1 2026", concatenate in a custom column rather than editing the record.
- Use DayOfWeek as a 0-6 number with Sunday as 0; combine it with DayName when you want a readable weekday but a stable sort.
- Preview the record before expanding. Clicking the word Record in a cell shows every field and value, which is the quickest way to confirm the input date is what you expected.
Troubleshooting
If you get a conversion error, first check the column type and the locale. In the Power Query Editor use Home > Data Type to set Date, and check the source step for a changed type step that uses a different culture. A date written 03/04/2026 is March 4 in US settings and April 3 in UK settings, so a wrong locale produces a valid but wrong date rather than an error.
If the new column shows errors on some rows only, find the offending rows by filtering the column for errors and inspecting the source values: blanks, empty strings, stray spaces, or text such as "N/A" are the usual causes. Replace or filter those values before the Date.ToRecord step, or wrap it with try ... otherwise null. For example, try Date.ToRecord([Order Date]) otherwise null keeps the query refreshing and leaves a null you can handle downstream.
If expanding gives more or fewer fields than expected, make sure you used Date.ToRecord rather than a different record function, and that the input is Date, not DateTime or DateTimeZone. Those types return a larger record, including Time, and expanding them creates columns you probably do not want.
If refresh is slow on a large table, expand only the fields you use. Each field becomes a column and a column of records is more expensive to expand than one with only a few fields.
Frequently Asked Questions
What fields does Date.ToRecord return?
The record includes Year, Month, Day, Quarter, DayOfWeek, DayOfYear, WeekOfYear, MonthName and DayName. The exact field list and ordering is fixed by the function, so you can rely on the names in the expand dialog.
Does it work on a DateTime column?
Yes, but it returns a larger record including time fields. Convert the column to Date first if you only need the calendar parts; that step discards the time component, so do it only when the time is genuinely unneeded.
Can I use it in a calculated column in Power BI's data model?
No. Date.ToRecord is a Power Query (M) function and belongs in the query editor. In a DAX calculated column you would use YEAR, MONTH and DAY functions instead.
Is there a way to get just one part, such as the month?
Yes. Use Date.Month([Order Date]) for the number or Date.MonthName([Order Date]) for the name, as a custom column. Date.ToRecord is the better choice only when you want several parts at once.
Will the date parts update when the source changes?
Yes. The custom column and expand steps are recalculated on every refresh, so edited dates produce updated Year, Month and other fields automatically.