Datetime help

A

AVL

Hi,
I've need some info regarding datetime conversions..
I've a string in the below format'"dd/mm/yyyy"..I want it to be converted to
Datetime object with the date format as "mm/dd/yyyy"
I've used the below code..

Dim provider As IFormatProvider
provider = New System.Globalization.CultureInfo("en-US", True)
drnewRow("Inv_Date_Detail") = DateTime.ParseExact("21/11/2007",
"dd/MM/yyyy", provider).ToShortDateString()

This workds fine if my current culture in regional settings is "en-US"..
but fails when I move my current culture to 'en-GB"..

I want a generic solution to this..
how shud i convert a "dd/mm/yyyy" to "mm/dd/yyyy" in vb/net?
 
M

Mark Rae [MVP]

I want a generic solution to this..
how should i convert a "dd/mm/yyyy" to "mm/dd/yyyy" in vb/net?

Try this:
drnewRow("Inv_Date_Detail") = DateTime.ParseExact("21/11/2007",
"dd/MM/yyyy", Nothing).ToShortDateString()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top