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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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