Barguast

Is there any way to specify that the ordinal suffix for the day number (st, nd, rd, th) should be used when using the ToString method For example, so I can format the date in the form "2nd January 2007"

I know there are ways to do this manually, but I need a way to do it via the ToString method.


Re: .NET Base Class Library DateTime.ToString (Day ordinal suffix)

nobugz

I see nothing in the custom DateTime formatting strings. Beware of cultural differences...





Re: .NET Base Class Library DateTime.ToString (Day ordinal suffix)

Geert Verhoeven

Hi Barguast,

There is no format specifier that gives you this result. If you want to have this kind of result, you will need to implement a function that receives a number as parameter and returns the string you need.

Here is a reference to all the possible format specifiers: http://msdn2.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.aspx

Greetz,

Geert

Geert Verhoeven
Consultant @ Ausy Belgium

My Personal Blog