Forum Discussion

edubcardoso's avatar
edubcardoso
Icon for Advocate I rankAdvocate I
4 years ago
Solved

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 ?

  • 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.

2 Replies

  • Vijay_A_Verma's avatar
    Vijay_A_Verma
    Icon for Most Valuable Professional rankMost Valuable Professional

    Change DateTime.ToText(Source) to

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

  • 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.