|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VB.NET (ASP) Can't convert Dates...help!I've converted string representations of Dates into DATE types alot
before in Windows Apps, I'm just doing the same now in a Web App, I'm fairly new to ASP.NET, but the error does not make sense at all: System.InvalidCastException: Cast from string "14:13:00 21/03/2005" to type 'Date' is not valid. To which I reply "yes it #!$%#% is!!" Now, I've seen it before where you try to convert an empty string to a date, and of course the poor thing can't convert it, but the above looks like a date to me...I'm in the UK so 21 is the day not the month. Maybe this is what its refering to, I have the regional settings, set to UK style dates, so it should be able to interpret it. So, whats happening here? Scott Hi,
Dim d As DateTime = DateTime.ParseExact("14:13:00 21/03/2005", "HH:mm:ss dd/MM/yyyy", New Globalization.CultureInfo("en-US")) Ken -------------------- "Scott H" <e@mc.sqr> wrote in message I've converted string representations of Dates into DATE types alotnews:esdi41tofs4toa4efg23567nh0t9mdp47f@4ax.com... before in Windows Apps, I'm just doing the same now in a Web App, I'm fairly new to ASP.NET, but the error does not make sense at all: System.InvalidCastException: Cast from string "14:13:00 21/03/2005" to type 'Date' is not valid. To which I reply "yes it #!$%#% is!!" Now, I've seen it before where you try to convert an empty string to a date, and of course the poor thing can't convert it, but the above looks like a date to me...I'm in the UK so 21 is the day not the month. Maybe this is what its refering to, I have the regional settings, set to UK style dates, so it should be able to interpret it. So, whats happening here? Scott Thanks Ken, that worked
Scott On Tue, 29 Mar 2005 06:34:33 -0500, "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote: Show quoteHide quote >Hi, > >Dim d As DateTime = DateTime.ParseExact("14:13:00 21/03/2005", "HH:mm:ss >dd/MM/yyyy", New Globalization.CultureInfo("en-US")) > > > >Ken > >-------------------- > >"Scott H" <e@mc.sqr> wrote in message >news:esdi41tofs4toa4efg23567nh0t9mdp47f@4ax.com... > >I've converted string representations of Dates into DATE types alot >before in Windows Apps, I'm just doing the same now in a Web App, I'm >fairly new to ASP.NET, but the error does not make sense at all: > >System.InvalidCastException: Cast from string "14:13:00 21/03/2005" to >type 'Date' is not valid. > >To which I reply "yes it #!$%#% is!!" >Now, I've seen it before where you try to convert an empty string to a >date, and of course the poor thing can't convert it, but the above >looks like a date to me...I'm in the UK so 21 is the day not the >month. Maybe this is what its refering to, I have the regional >settings, set to UK style dates, so it should be able to interpret it. > >So, whats happening here? > >Scott > Ken,
Probably in the UK > Dim d As DateTime = DateTime.ParseExact("14:13:00 21/03/2005", "HH:mm:ss Typo because the date is correct> dd/MM/yyyy", New Globalization.CultureInfo("en-UK")) :-) CorScott,
> System.InvalidCastException: Cast from string "14:13:00 21/03/2005" to AFAIK is a standard datetime string in the complete EU "21/03/2005 14:13:00"> type 'Date' is not valid. Cor Thanks Cor, I noticed while playing around with Ken's Suggested code
that Some date values had the time first, others had the date first. On Tue, 29 Mar 2005 17:10:00 +0200, "Cor Ligthert" <notmyfirstn***@planet.nl> wrote: Show quoteHide quote >Scott, > >> System.InvalidCastException: Cast from string "14:13:00 21/03/2005" to >> type 'Date' is not valid. > >AFAIK is a standard datetime string in the complete EU "21/03/2005 14:13:00" > >Cor >
64 HI/LO DWORD extraction vb.net
Excel ADO question Using a variable to specify the name of a control Datalist/datatable sorting Cannot Get MenuItem's name[Notsolved] Formatting timespan objects how to use CurrentRowIndex for datagrid control ? memory stream XML and unicode problem Writing E-Mail Notfications VB.NET with ADO.NET compilation error. |
|||||||||||||||||||||||