开发者

Date format issue

I'm facing problem while conversion of date

if I used -- Date.parse("28/01/2011") it gives me error as

"String was not recognized as a valid DateTime."

so then I modify above code as -- CDate("28/01/2011") it gives me error as

"Cast from string "28/01/2011" to type 'Date' is not valid."

I used convert.todatetime also开发者_运维问答 date.parseexact but nothing is working...

I'm using VS2003 in asp.net1.1 with vb.net


Probably Parse is using InvariantCulture date format "MM/dd/yyyy". Maybe you can try with

DateTime.ParseExact("28/01/2011", "dd/MM/yyyy", CultureInfo.InvariantCulture)

or passing a correct culture on Parse, like spanish that has date format dd/MM/yyyy

Date.Parse("28/01/2011", new CultureInfo("es-ES", true));

Write from memory, maybe is not accurate

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜