By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,424 Members | 1,375 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,424 IT Pros & Developers. It's quick & easy.

DateFormat 03/05 to MAR05, how?

P: n/a
I have a DateTime type data for my grid column. I want to display it in the
cells as

MONYR, as MAR05 JAN05 etc. Cannot find it in DateTime format, is there any
quick way to do it (instead of convert my column type from DateTime to string
and then parse it by myself)?

Thanks a lot

Chris
Nov 16 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
DateTime.ToString("MMMYY") ?

(You may need to do a ToUpper if you want the month in capital letters).

--
Adam Clauss
ca*****@tamu.edu

"chrisben" <ch******@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
I have a DateTime type data for my grid column. I want to display it in the
cells as

MONYR, as MAR05 JAN05 etc. Cannot find it in DateTime format, is there any
quick way to do it (instead of convert my column type from DateTime to
string
and then parse it by myself)?

Thanks a lot

Chris

Nov 16 '05 #2

P: n/a
Chrisben,

http://msdn.microsoft.com/library/de...ormattopic.asp

"MMMdd"

I hope this helps

Cor
Nov 16 '05 #3

P: n/a
chrisben <ch******@discussions.microsoft.com> wrote:
I have a DateTime type data for my grid column. I want to display it in the
cells as

MONYR, as MAR05 JAN05 etc. Cannot find it in DateTime format, is there any
quick way to do it (instead of convert my column type from DateTime to string
and then parse it by myself)?


You mean something like:

using System;

public class Foo
{
public static void Main()
{
DateTime dt = DateTime.Now;
Console.WriteLine(dt.ToString("MMMyy").ToUpper());
}
}

The month name used is Culture specific so is capable of being
localized.

/J\
Nov 16 '05 #4

P: n/a
Thanks a lot Adam. It works. Hard to toupper since I define the column type
as datatime and the format is predefined. however, i can live with it.
Thanks again for quick response

Chris

"Adam Clauss" wrote:
DateTime.ToString("MMMYY") ?

(You may need to do a ToUpper if you want the month in capital letters).

--
Adam Clauss
ca*****@tamu.edu

"chrisben" <ch******@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
I have a DateTime type data for my grid column. I want to display it in the
cells as

MONYR, as MAR05 JAN05 etc. Cannot find it in DateTime format, is there any
quick way to do it (instead of convert my column type from DateTime to
string
and then parse it by myself)?

Thanks a lot

Chris


Nov 16 '05 #5

P: n/a
thanks a lot, Cor.

"Cor Ligthert" wrote:
Chrisben,

http://msdn.microsoft.com/library/de...ormattopic.asp

"MMMdd"

I hope this helps

Cor

Nov 16 '05 #6

P: n/a
Thanks Jonathan. Sorry for my ignorance. Would you please explain what
"Culture specific" means?
"Jonathan Stowe" wrote:
chrisben <ch******@discussions.microsoft.com> wrote:
I have a DateTime type data for my grid column. I want to display it in the
cells as

MONYR, as MAR05 JAN05 etc. Cannot find it in DateTime format, is there any
quick way to do it (instead of convert my column type from DateTime to string
and then parse it by myself)?


You mean something like:

using System;

public class Foo
{
public static void Main()
{
DateTime dt = DateTime.Now;
Console.WriteLine(dt.ToString("MMMyy").ToUpper());
}
}

The month name used is Culture specific so is capable of being
localized.

/J\

Nov 16 '05 #7

P: n/a
chrisben <ch******@discussions.microsoft.com> wrote:
"Jonathan Stowe" wrote:
chrisben <ch******@discussions.microsoft.com> wrote:
> I have a DateTime type data for my grid column. I want to display
> it in the cells as MONYR, as MAR05 JAN05 etc. Cannot find it in
> DateTime format, is there any quick way to do it (instead of convert
> my column type from DateTime to string and then parse it by myself)?
>


You mean something like:

using System;

public class Foo
{
public static void Main()
{
DateTime dt = DateTime.Now;
Console.WriteLine(dt.ToString("MMMyy").ToUpper());
}
}

The month name used is Culture specific so is capable of being
localized.

/J\

Thanks Jonathan. Sorry for my ignorance. Would you please explain what
"Culture specific" means?


'Culture' is a .NETism for what is commonly called 'locale' in other
places, essentially it is a set of rules for how things like dates,
time, currency and so forth are represented in different locatlities.
See for instance the output of this slightly altered version of the above:

using System;

public class Foo
{
public static void Main()
{
DateTime dt = DateTime.Now;
IFormatProvider format = new System.Globalization.CultureInfo("en-GB", true);
Console.WriteLine(dt.ToString("MMMyy",format).ToUp per());
format = new System.Globalization.CultureInfo("de-DE", true);
Console.WriteLine(dt.ToString("MMMyy",format).ToUp per());
format = new System.Globalization.CultureInfo("ru-RU", true);
Console.WriteLine(dt.ToString("MMMyy",format).ToUp per());

}
}
The second argument to ToString() indicates the 'locale' that is to be
used in formatting the date.

/J\
Nov 16 '05 #8

P: n/a
thanks

"Jonathan Stowe" wrote:
chrisben <ch******@discussions.microsoft.com> wrote:
"Jonathan Stowe" wrote:
chrisben <ch******@discussions.microsoft.com> wrote:
> I have a DateTime type data for my grid column. I want to display
> it in the cells as MONYR, as MAR05 JAN05 etc. Cannot find it in
> DateTime format, is there any quick way to do it (instead of convert
> my column type from DateTime to string and then parse it by myself)?
>

You mean something like:

using System;

public class Foo
{
public static void Main()
{
DateTime dt = DateTime.Now;
Console.WriteLine(dt.ToString("MMMyy").ToUpper());
}
}

The month name used is Culture specific so is capable of being
localized.

/J\

Thanks Jonathan. Sorry for my ignorance. Would you please explain what
"Culture specific" means?


'Culture' is a .NETism for what is commonly called 'locale' in other
places, essentially it is a set of rules for how things like dates,
time, currency and so forth are represented in different locatlities.
See for instance the output of this slightly altered version of the above:

using System;

public class Foo
{
public static void Main()
{
DateTime dt = DateTime.Now;
IFormatProvider format = new System.Globalization.CultureInfo("en-GB", true);
Console.WriteLine(dt.ToString("MMMyy",format).ToUp per());
format = new System.Globalization.CultureInfo("de-DE", true);
Console.WriteLine(dt.ToString("MMMyy",format).ToUp per());
format = new System.Globalization.CultureInfo("ru-RU", true);
Console.WriteLine(dt.ToString("MMMyy",format).ToUp per());

}
}
The second argument to ToString() indicates the 'locale' that is to be
used in formatting the date.

/J\

Nov 16 '05 #9

P: n/a
Jonathan,

However this what you wrote is in my opinion not true
The month name used is Culture specific so is capable of being
localized.


MMM is forever the short name month abbreviation, from the language that is
used, in the OS and is not depending from the culture. While dd is always
the day in two figures.

Cor
Nov 16 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.