Date format

hello,

I have a field in '05/01/2006' format and I'd like to change it to '01-MAY-06' format in VB.net.
Any ideas?

Thanks,
mrongAsked:
Who is Participating?
 
Shiju SasidharanAssoc Project ManagerCommented:

   UCase(Format(CDate("05/01/2006"), "dd-MMM-yy"))
0
 
bruintjeCommented:
Hello mrong,

you could try something like
----------
Dim MyString As String = UCase(MyDate.ToString("d - MMM - yyyy"))
----------
where MyDate is your date variable

hope this helps a bit
bruintje
0
 
bruintjeCommented:
Dim MyString As String = UCase(MyDate.ToString("dd-MMM-yyyy"))
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
possekeCommented:
String.Format('05/01/2006', "dd-MMMM-yy") should work

On this site you have all the different types of Formats dat can be used to convert a date:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcustomdatetimeformatstrings.asp

Read it !!

Greetz,

Po$$e
0
 
Shiju SasidharanAssoc Project ManagerCommented:
or simply

       Format(CDate("05/01/2006"), "dd-MMM-yy")
0
 
bruintjeCommented:
problem with that is you get 'May' instead of 'MAY'
0
 
mrongAuthor Commented:
Bruintje,

I tried your suggestions and got the following error:
System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.IFormatProvider'.


Shijusn, your code works for me.

Thank everyone of you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.