How to display "from" within DateTimePicker

2

No DateTimePicker I can display anything using d for day, MM or MMMM for month and yy or yyyy for year.

However, I would like to simply display in the customformat property: April 15th.

However, when I write:

dtApartir.CustomFormat = "d de MMMM de yyyy";

Results in:

  

15 15e April 15e 2014.

Is there any way around this and display the "d" of "from"?

    
asked by anonymous 15.04.2014 / 21:36

3 answers

2

Use single quotes inside the string, just like substrings:

dtApartir.CustomFormat = "d' de 'MMMM' de 'yyyy";
    
15.04.2014 / 21:46
0

This happens because C # interprets the letter 'd' of the word 'as' as the letter ' d ' reserved for the number format of the day.

Do not forget to set Format , too:

dtApartir.CustomFormat = String.Format("d {0} MMMM {0}", "'de'");
dtApartir.Format = DateTimePickerFormat.Custom;
    
15.04.2014 / 21:54
0

Use barra invertida \ .

  

To prevent a character from being interpreted as a specifier   format, you can precede it with a backslash \ , which is the   escape character.

     

The escape character means that the following is   a literal character that must be included in the result string   unchanged.

Do this:

 dtApartir.CustomFormat = "d \de MMMM \de yyyy";
    
15.04.2014 / 21:42