开发者

i get date in wrong format - need help

i ge开发者_JAVA百科t date from xml in this format: 7/16/2010 (mm/dd/yyyy)

i have in my program datetime val - MyDate.

and when i try to placing MyDate = Convert.ToDateTime(7/16/2010)

i got error.

how i can fix it ?

thank's in advance


DateTime MyDate = DateTime.ParseExact("7/16/2010", "M/dd/yyyy", CultureInfo.InvariantCulture);


do you need to delimit your date with double-quotes?

MyDate = Convert.ToDateTime("7/16/2010")

as it's converting from string?


DateTime.Parse("7/16/2010");

Here is a link to the DateTime.Parse documentation.

Enjoy!


MyDate = #7/16/2010#
but first you have to switch to VB ;-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜