Home All Groups Group Topic Archive Search About

Converting String to date

Author
14 Apr 2006 9:33 AM
Joris De Groote
Hi,

I have a date: "7/10/2006"
I convert it with this: Convert.ToDateTime(DocumentDatum)
Now I get this: "10/7/2006"
How can I make sure that it doesn't change month & day?

Thanks
Joris

Author
14 Apr 2006 11:55 AM
OHM ( One Handed Man )
Here's one way
Debug.WriteLine(Convert.ToDateTime("12/3/2006", New
Globalization.CultureInfo("en-GB")).ToShortDateString)


--
( OHM ) - One Handed Man
AKA Terry Burns - http://TrainingOn.net
Show quoteHide quote
"Joris De Groote" <joris.degro***@skynet.be> wrote in message
news:%23DmB2Z6XGHA.4684@TK2MSFTNGP03.phx.gbl...
> Hi,
>
> I have a date: "7/10/2006"
> I convert it with this: Convert.ToDateTime(DocumentDatum)
> Now I get this: "10/7/2006"
> How can I make sure that it doesn't change month & day?
>
> Thanks
> Joris
>
>
Author
14 Apr 2006 12:33 PM
Herfried K. Wagner [MVP]
"Joris De Groote" <joris.degro***@skynet.be> schrieb:
> I have a date: "7/10/2006"
> I convert it with this: Convert.ToDateTime(DocumentDatum)
> Now I get this: "10/7/2006"
> How can I make sure that it doesn't change month & day?

Check out 'DateTime.ParseExact'.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>