question

PadmanabhanVenkatesh-6789 avatar image
0 Votes"
PadmanabhanVenkatesh-6789 asked AgaveJoe commented

Date format ddMMMYYYY

Hi.

I have a datetime field which has date in the format of 31/07/2021 00:00:00

I am trying to convert it to a string which has format of '31JUL2021' . The string should contain the single quotes and using the above format.

I have tried the dd/MMM/YYYY format, but do not need the / in it. Is there any other option to convert it?
Thanks

dotnet-csharp
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Standard and custom date formats are covered in the reference documentation.


1 Vote 1 ·

1 Answer

Viorel-1 avatar image
1 Vote"
Viorel-1 answered

Check an example:

 DateTime date = new DateTime( 2021, 07, 31 );
 CultureInfo ci = CultureInfo.GetCultureInfo( "en-US" );
 string result = date.ToString( @"\'dd''MMM''yyyy\'", ci ).ToUpper( );
 Console.WriteLine( result );


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.