-2

Is there a way to format DateTime into the following String in C#?:

29JUN91

I cant find anything online that allows us to write the month in short string form.

HelpASisterOut
  • 3,085
  • 16
  • 45
  • 89

3 Answers3

3

Have a look at MSDN for custom date formating

DateTime input = new DateTime(1991, 6, 29); //29JUN91
string result = input.ToString("ddMMMyy").ToUpper();
  • dd for 2 digit day
  • MMM for abbreviated name of the month
  • yy for 2 digit year, from 00 to 99
fubo
  • 44,811
  • 17
  • 103
  • 137
1

Try to use ToString("ddMMMyy")

DateTime.Now.ToString("ddMMMyy"); // case sensitive

use .ToUpper(); if you want to convert month in upper case.

MANISH KUMAR CHOUDHARY
  • 3,396
  • 3
  • 22
  • 34
0
   DateTime.Now.ToString("ddMMMyy").ToUpper();
kgzdev
  • 2,770
  • 2
  • 18
  • 35