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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
edubcardoso
Advocate I
Advocate I

How to convert todays date to text, with a specific format ?

I need to convert the current date to text so i can join it to a string.

let
    Source = DateTime.LocalNow(),
    Text = DateTime.ToText(Source)       
in
    Text

I have this, but the output is 09/09/2022 12:31:23 and I need 2022-09(MONTH)-09(DAY)

 

How can I solve this ?

2 ACCEPTED SOLUTIONS
Vijay_A_Verma
Super User
Super User

Change DateTime.ToText(Source) to

DateTime.ToText(Source,"yyyy-MM-dd")

View solution in original post

ronrsnfld
Super User
Super User

Depending on exactly what you want, maybe:

 

 DateTime.ToText(DateTime.LocalNow(),"yyyy-MM(MMMM)-dd(dddd)") 
      => 2022-09(September)-09(Friday)

or

DateTime.ToText(DateTime.LocalNow(),"yyyy-MM(""MONTH"")-dd(""DAY"")") 
     => 2022-09(MONTH)-09(DAY)

 

 

 

 

here, today.

View solution in original post

2 REPLIES 2
ronrsnfld
Super User
Super User

Depending on exactly what you want, maybe:

 

 DateTime.ToText(DateTime.LocalNow(),"yyyy-MM(MMMM)-dd(dddd)") 
      => 2022-09(September)-09(Friday)

or

DateTime.ToText(DateTime.LocalNow(),"yyyy-MM(""MONTH"")-dd(""DAY"")") 
     => 2022-09(MONTH)-09(DAY)

 

 

 

 

here, today.

Vijay_A_Verma
Super User
Super User

Change DateTime.ToText(Source) to

DateTime.ToText(Source,"yyyy-MM-dd")

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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