• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3511
  • Last Modified:

format date dd-mmm-yyyy in .NET

I want to convert a date from dd-mm-yyyy format to dd-mmm-yyyy in .NET

eg

dim strdate as string
strdate = 02-04-2006

i want strdate to be 02-APR-2006

how do i do this.

thank you
0
pratikshahse
Asked:
pratikshahse
1 Solution
 
Arthur_WoodCommented:
dim strDate as new DateTime(2006, 4,2)

MessageBox.Show("The Date is " & strDate.ToString("dd-MMM-yyyy"))

AW

0
 
pratikshahseAuthor Commented:
this is what i have

dim strdate as new datetime

strdate = Request.Form("txtstdate")  -----> This is coming from a datepicker on placed on my webform in the format of dd-mm-yyyy
strdate  = strdate.tostring("dd-MMM-yyyy")

this does not do anything. the date still remains in the format of 02-4-2006. instead i want it to be 02-APR-2006.
0
 
FocusynCommented:
You're using a string format provider and passing a string value to a datetime object, causing an implicit cast; have you tried instantiating a string and then using same code?  i.e.:

dim strdate as new datetime

strdate = Request.Form("txtstdate")
Dim strformatteddate as String  = strdate.tostring("dd-MMM-yyyy")


0
 
bhagavan2udayCommented:
Hi,
         Its simplest solution is

         MessageBox.Show(strDt.ToString("dd-mmm-yy"))


Regards,
Uday
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now