tags:

views:

355

answers:

2

hi guys, i hve a textbox in which date is coming in mm/dd/yyyy. i want to convert it from mm/dd/yyyy to dd/mm/yyyy in asp.net with vb to a variable which is datetime

+4  A: 
DateTime.ParseExact("12/21/2008", "MM/dd/yyyy", CultureInfo.InvariantCulture).ToString("dd'/'MM'/'yyyy")

Update: Given that you want to have a DateTime in the end, you can just parse the original format:

DateTime.ParseExact("12/21/2008", "MM/dd/yyyy", CultureInfo.InvariantCulture)

The date formats are of use only when presenting the date as a string (internally the date does not have a format; it's just a number). If you want to store it in a DateTime all you need to bother about is to interpret the input correctly.

Fredrik Mörk
A: 

If you are dealing with a DateTime object you convert can like this:

yourDateTime.ToString("dd/MM/yyyy"))
Vadim