format date dd-mmm-yyyy in .NET

Posted on 2006-04-03
Last Modified: 2012-06-21
I want to convert a date from dd-mm-yyyy format to dd-mmm-yyyy in .NET


dim strdate as string
strdate = 02-04-2006

i want strdate to be 02-APR-2006

how do i do this.

thank you
Question by:pratikshahse
    LVL 44

    Expert Comment

    dim strDate as new DateTime(2006, 4,2)

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



    Author Comment

    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.
    LVL 7

    Accepted Solution

    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")

    LVL 10

    Expert Comment

             Its simplest solution is



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
    This is about my first experience with programming Arduino.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now