Dim data As Date = Date.ParseExact("11/11/2004", "dd/mm/yyyy",
System.Globalization.DateTimeFormatInfo.InvariantInfo)
System.Console.Out.WriteLine(data.ToString)
i got:
2004-01-11 00:11:00
Why the type is Datetime while i declared Date, and why the time is
set to 00:11?
Regards
Mirek
Basically, your format string is wrong.
Dim data as DateTime = Date.ParseExact("11/11/2004","d", _
System.Globalization.DateTimeFormatInfo.InvariantInfo)
returns "11/11/2004 12:00:00 AM".
"d" stands for "short date", which is "mm/dd/yyyy" format in the US,
dd/mm/yyyy in the UK (etc) style.
The time is 00:11 because mm in your format string stands for minutes. If
you really want to be specific about the format string, use the right
entries:
Dim data = Date.ParseExact("11/11/2004", "dd/MM/yyyy", _
System.Globalization.DateTimeFormatInfo.InvariantInfo)
In .Net, DateTime is used for dates and times. If you only want one part,
you'll have to handle that in the formatting, or however you are using it.
They are always together.
RobinS.
GoldMail, Inc.
----------------------------------
<mirek.le...@gmail.com> wrote in message
news:2c4cb7df-853d-4716...@i7g2000prf.googlegroups.com...