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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
shuhn1229
Resolver I
Resolver I

Convert Date to String

Hi all,

 

Pretty basic question. I'm trying to filter out all files that do not contain today's date in the file name. For this I have: 

 

Table.SelectRows(#"Renamed Columns1", each Text.Contains([Source.Name], "DATE"))

 

I am trying to replace "DATE" with Date.toFrom(DateTime.LocalNow()), so that this can be dynamic, but this throws a conversion error. Can anyone help with this?

 

Thanks!

1 ACCEPTED SOLUTION

Date.ToText(Date.From(DateTime.LocalNow()),[Format="ddMMMyyyy"])

View solution in original post

3 REPLIES 3
Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

Hi @shuhn1229 - you need to consider one of the following to convert Date/DateTime to Text:

Date.ToText - PowerQuery M | Microsoft Learn
DateTime.FromText - PowerQuery M | Microsoft Learn
Text.From - PowerQuery M | Microsoft Learn

 

The second is probably better as you can define the format for the Datetime straight to DD-MM-YYYY (for example) without using Date.From step.


Here is good resource that list the date formats options:

Date Formatting in Power Query - Master 18 Custom Formats (gorilla.bi)

Hi thanks, this is great. I used Text.From(DateTime.Date( DateTime.LocalNow() )) and recieved the value 11/03/23, which is great. I hate to bug but unfortunately / cannot be used in file names. How would I got about dropping them?

Date.ToText(Date.From(DateTime.LocalNow()),[Format="ddMMMyyyy"])

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors