Forum Discussion
DAX Query Format Date
- 7 months ago
You can use the following DAX query to return only a formatted date, avoiding the ugly datetime string when copying to Excel:
EVALUATE
SELECTCOLUMNS(
Bookings,
"xDate", FORMAT(Bookings[Date], "MM/DD/YYYY")
)- This will output only the xDate column with dates formatted as MM/DD/YYYY.
- Excel will see the result as plain text, so the original datetime format like Wed, 01 Jan 2025 00:00:00 is avoided.
- You don’t need to reference the original Bookings[Date] column separately, which keeps your solution clean and avoids violating DRY principles.
If this answer helped, please click Kudos or Accept as Solution.Best regards,
Vaibhav Mahajan
- 7 months ago
Thanks Kedar_Pande
Does not work for me.
Hi tecumseh,
I tried to reproduce your scenario using a small sample Bookings table, and I was able to get the expected US-formatted date output by using the following DAX query:
EVALUATE
ADDCOLUMNS(
VALUES(Bookings[Date]),
"xDate", FORMAT(Bookings[Date], "MM/DD/YYYY")
)
This approach ensures that each date is formatted correctly as MM/DD/YYYY without returning the long datetime string you were seeing earlier. I’m attaching the sample .pbix file I used, in case you’d like to compare it with your model or test the behavior on your side.
Best regards,
Ganesh Singamshetty.
- tecumseh7 months agoResolver III
v-ssriganesh
Yes, similar to my original post.
But my goal was to try to figure out how to get the formatted date without repeating Bookings[Date]. Feels like violating DRY (Don't Repeat Yourself)
Thanks,w