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

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

Reply
AnkitaChatterje
Frequent Visitor

How to change date to text without changing the format?

Hi,

 

I want to import certain jsons automatically from a URL and accordingly I have written a query in power BI Query Editor which incorporates the system date to fetch the current date json. The current date format should be "YYYY-MM-DD". Further, I have to convert the date to "text" format to construct the json URL, but it is changing the format to "MM/DD/YYY" which is causing an error while connecting to the URL.

 

Kindly suggest me a command which will convert my date to text without changing the format (i.e. "YYYY-MM-DD").

 

Here's the query that I have written so far :

Pic for Power BI.JPG

1 ACCEPTED SOLUTION

Hi @AnkitaChatterje,

 

Actually, I used the same code with yours. Please refer to m/date-totext. Maybe we can add one more parameter to Date.ToText.

let
    Source = Date.ToText(DateTime.Date(DateTime.LocalNow()), "yyyy-MM-dd"),
    #"Converted to Table" = #table(1, {{Source}})
in
    #"Converted to Table"

Please give it a try.

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @AnkitaChatterje,

 

Please set up a proper value for "Regional Settings -> Locale for import". Please refer to the snapshot below.

How_to_change_date_to_text_without_changing_the_format

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi,

 

Thanks for your suggestion. But this won't work in my case. In this case, I don't have a list of dates or a table with "Date" column. I have to use the current date (which I am extracting from system date) and further convert it to type text in order to fetch data from a API which is date dependent.

 

Here's the query that I have written so far :

let
     Date = Date.ToText( DateTime.Date(DateTime.LocalNow()) )

in

     Date

 

But the command "Date.ToText()" is changing the format of "Date" to "M/DD/YYYY" while I need to publish the "Date" in the format "YYYY-MM-DD" (exactly in this format).

 

Kindly suggest me a way to incorporate this in power query.

Hi @AnkitaChatterje,

 

Actually, I used the same code with yours. Please refer to m/date-totext. Maybe we can add one more parameter to Date.ToText.

let
    Source = Date.ToText(DateTime.Date(DateTime.LocalNow()), "yyyy-MM-dd"),
    #"Converted to Table" = #table(1, {{Source}})
in
    #"Converted to Table"

Please give it a try.

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you....the last one solved my problem.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.