Date Time Casting Problem

  • Thread starter Thread starter ed
  • Start date Start date
E

ed

I read a similar post on the group :

http://groups.google.co.uk/groups?q...F-8&selm=eRvILbWECHA.1548@tkmsftngp05&rnum=15

I'm having a similar problem.

My set up is : windows 2000 sever (all regional settings set to
british / UK)
SQLserver 2000 : (user account has default lang set to british (UK))
..net framework erm... 1.1.4322 i think.

when i run the following sql in the querry anylser it works fine:
SELECT t_reminder.intReminderID,Convert(char(10),t_reminder.dtmReminderDate,103)
FROM t_reminder ORDER BY t_reminder.dtmReminderDate ASC
Put it in as aspx page and i get an error:
Cast from string "30/07/2004" to type 'Date' is not valid.

Using the following command as detailed in the above article:
Response.Write(System.Threading.Thread.CurrentThread.CurrentCulture.EnglishName)
I got English (United States).

I'm tearing my hair out (what little I have) over this.. does any one
have any ideas??
 
ed said:
I read a similar post on the group :

http://groups.google.co.uk/groups?q...F-8&selm=eRvILbWECHA.1548@tkmsftngp05&rnum=15

I'm having a similar problem.

My set up is : windows 2000 sever (all regional settings set to
british / UK)
SQLserver 2000 : (user account has default lang set to british
(UK)) .net framework erm... 1.1.4322 i think.

when i run the following sql in the querry anylser it works fine:
SELECT
t_reminder.intReminderID,Convert(char(10),t_reminder.dtmReminderDate,103)
FROM t_reminder ORDER BY t_reminder.dtmReminderDate ASC
Put it in as aspx page and i get an error:
Cast from string "30/07/2004" to type 'Date' is not valid.

Using the following command as detailed in the above article:
Response.Write(System.Threading.Thread.CurrentThread.CurrentCulture.EnglishN
ame)
I got English (United States).

I'm tearing my hair out (what little I have) over this.. does any
one have any ideas??



Why not use the format the server is expecting in an SQL string? I think the
format #07/30/2004# should work. To convert a date value to this string use
"#" & <DateTime>.ToString("MM/dd/yyyy") & "#". I'm not sure if that's
exactly the format the server expects but you can look it up in the T-SQL
manual.

I guess you are using ADO.NET. The question is not specific to VB.NET
programming, so I think microsoft.public.dotnet.framework.adonet is the more
appropriate group.

You should also have a look at the Parameters property and have ADO.NET
create the complete SQL string for you.
 
I had a similar problem, the result I found was that SQL
formats all dates as mm/dd/yy irrespective of system date
therefore all dates processed should first be formated
mm/dd/yy

hope this helps

-----Original Message-----

q=.net+cast+string+date+valid+sql&start=10&hl=en&lr=&ie=UTF
-8&oe=UTF-8&selm=eRvILbWECHA.1548%40tkmsftngp05&rnum=15
(System.Threading.Thread.CurrentThread.CurrentCulture.Engli
shN



Why not use the format the server is expecting in an SQL string? I think the
format #07/30/2004# should work. To convert a date value to this string use
"#" & <DateTime>.ToString("MM/dd/yyyy") & "#". I'm not sure if that's
exactly the format the server expects but you can look it up in the T-SQL
manual.

I guess you are using ADO.NET. The question is not specific to VB.NET
programming, so I think
microsoft.public.dotnet.framework.adonet is the more
 
Back
Top