Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
tecumseh
Resolver III
Resolver III

DateToText Swaps Month and Day Python Microsoft.OleDb.Date

Hi all,

Using PBID April 2025.
I'm using a Python Script to export a dataframe to csv file
All of the date columns are returning Microsoft.OleDb.Date
So I need to convert all date columns to text before I export to csv

I tried DateToText. but it is swapping the the month to the day position
How do I retain the original date as a text string?

Thanks,

w

date_text_error.png

1 ACCEPTED SOLUTION
tecumseh
Resolver III
Resolver III

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.

View solution in original post

3 REPLIES 3
v-hashadapu
Community Support
Community Support

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:

Date.ToText
Text.From

 

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.

tecumseh
Resolver III
Resolver III

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 ,

Alternatively try using Text.From()

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.