Forum Discussion
DateToText Swaps Month and Day Python Microsoft.OleDb.Date
- 1 year ago
Guess I need to specify the format string
Date.ToText([CAMPAIGN_START_DATE], [Format="MM/dd/yyyy"])
A little odd that Month must be uppercase MM then day and year are lowercase.
Hi tecumseh , Thank you for reaching out to the Microsoft Community Forum.
Try using Power Query’s Date.ToText() function with both a specified format string and culture setting. This avoids the issue where dates appear to swap month and day, due to locale-based formatting. For example, for a column like CAMPAIGN_START_DATE:
Date.ToText([CAMPAIGN_START_DATE], [Format="MM/dd/yyyy", Culture="en-US"])
Avoid using Text.From() in this scenario. While it does convert a date to text, it does not allow you to specify a custom format and instead uses the system’s locale settings. This means the month/day order could vary across environments, which is exactly the issue you're experiencing.
Please refer below documentation:
If this helped solve the issue, please consider marking it 'Accept as Solution' so others with similar queries may find it more easily. If not, please share the details, always happy to help.
Thank you.