Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Power Query Date.StartOfDay: How to Use It

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Date.StartOfDay is a Power Query M function that takes a date, datetime, or datetimezone value and returns a date value representing the very beginning of that day (midnight, 00:00:00). It is the quickest way to strip the time portion from a timestamp so you can group, filter, or join records by calendar date. You do not need any special add-in or license; the function is built into Power Query in Excel, Power BI, and other Microsoft products that host the Power Query engine.

What You'll Need

  • A version of Excel, Power BI Desktop, or another tool that includes Power Query (Excel 2016 and later, or a Microsoft 365 subscription, include it by default).
  • A table or query already loaded into Power Query with at least one column that contains date or datetime values.
  • Basic familiarity with the Power Query Editor: the ribbon, the formula bar, and the Applied Steps pane.

Step-by-Step

  1. Load your data into Power Query. In Excel, select your table and go to Data > From Table/Range. In Power BI Desktop, use Home > Transform data to open the Power Query Editor. The exact menu labels can differ slightly by version, device, or region, but the overall path is the same.
  2. Locate the column you want to convert. Find the column that holds the datetime values (for example, an OrderDateTime column). If the column is already type date, you can still apply the function, but it will simply return the same date.
  3. Add a custom column. On the Add Column tab, click Custom Column. In the dialog, give the new column a name such as OrderDate. In the formula box, type the function call using the exact column name from your table. For example, if the column is named OrderDateTime, enter:
    Date.StartOfDay([OrderDateTime])
    Column names are case-sensitive and must be enclosed in square brackets. If the column name contains spaces, you still use square brackets around the full name, e.g. Date.StartOfDay([Order DateTime]).
  4. Check the result type. After you click OK, Power Query adds a new step and shows the new column. The values will appear as dates (no time). If the column shows errors, see Troubleshooting below.
  5. Optional: change the column type explicitly. Right-click the new column header and choose Change Type > Date. This ensures downstream tools treat it as a date rather than a datetime with a zero time component.
  6. Use the new column. You can now filter, group, or merge on this date column. For example, use Group By to sum sales per day, or merge with a calendar table on the date column.
  7. Apply and close. In Excel, click Close & Load to send the results to a worksheet or the Data Model. In Power BI Desktop, click Close & Apply to load the query into the model.

Common Mistakes

  • Forgetting the square brackets around the column name. Writing Date.StartOfDay(OrderDateTime) without brackets causes an error because Power Query treats it as a function or variable, not a column reference.
  • Using the wrong column name. The name must match exactly, including capitalization and spaces. If you renamed a step earlier, the column name may have changed.
  • Passing a text value. If the column is typed as text (for example, "2024-01-15 14:30:00"), Date.StartOfDay will return an error. Convert the column to Date/Time first using the Transform tab > Data Type > Date/Time.
  • Expecting a datetime result. Date.StartOfDay returns a date, not a datetime. If you need a datetime at midnight, wrap the result with DateTime.From or use DateTime.Date.
  • Assuming it handles nulls. A null input returns null. If you need a default date for nulls, use a conditional expression such as if [OrderDateTime] = null then null else Date.StartOfDay([OrderDateTime]).

Tips

  • You can apply Date.StartOfDay directly in the formula bar by editing an existing step, but a custom column keeps the original value intact and is easier to audit.
  • If you only need to remove the time for display, you can change the column type to Date instead of adding a new column. However, changing the type may round or truncate differently depending on the source; Date.StartOfDay is explicit and predictable.
  • Combine with Date.EndOfDay to create start and end boundaries for a day, useful for filtering ranges.
  • For time zone-aware data, Date.StartOfDay works on the local date portion of a datetimezone value; it does not convert between time zones. Use DateTimeZone.ToLocal or similar functions if you need to shift zones first.
  • Name your custom column clearly, such as "Order Date (Start of Day)", so report users understand it is a date-only field.

Troubleshooting

  • Error: "We cannot convert the value ... to type Date." The column likely contains text or an incompatible type. Select the column, go to Transform > Data Type, and choose Date/Time. If the values are text, use Replace Values or a parsing step first.
  • Error: "The name 'Date.StartOfDay' wasn't recognized." This usually means a typo in the function name or that you are using an older version of Power Query that does not include the function. Check spelling and ensure your product is up to date.
  • All values show as errors. Confirm the column name in the formula matches the actual column header exactly. You can click the column header to see its name in the formula bar.
  • Nulls appear where you expected dates. The source value is null. Decide whether to filter out nulls or replace them with a default date using a conditional column.
  • The new column shows a time of 12:00:00 AM. That is expected: the underlying value is a date, and the display may include a time placeholder. Change the column type to Date to hide it.
  • Performance is slow on large tables. Adding a custom column is fine, but if you have millions of rows, consider filtering earlier or using Table.TransformColumns instead of a custom column to reduce overhead.

Frequently Asked Questions

What does Date.StartOfDay actually return?

It returns a date value (year, month, day) with no time component. In Power Query's data model, that is equivalent to midnight of that day.

Can I use Date.StartOfDay on a column that is already type Date?

Yes, it will return the same date. It is harmless but redundant; you can skip the step if the column is already date-only.

Does Date.StartOfDay work with datetimezone values?

Yes, it accepts date, datetime, and datetimezone inputs. For datetimezone, it returns the date portion in the value's own time zone; it does not convert to your local time zone.

How do I get the end of the day instead?

Use Date.EndOfDay, which returns the last moment of the day (typically 23:59:59.9999999).

Is there a difference between Date.StartOfDay and DateTime.Date?

DateTime.Date also extracts the date portion from a datetime value, but Date.StartOfDay is more explicit about the intent and works on date, datetime, and datetimezone types. Both return a date.

Can I use Date.StartOfDay in a calculated column in Power BI?

Yes, but only inside Power Query (M). In DAX, use the DATE function or FORMAT to achieve a similar result. Date.StartOfDay is not a DAX function.