smalldatetime problem

P

Pat

i'm passing a string as a Date as value :- for example "23/07/1988"
But when trying to insert it in a column with datatype "smalldatetime" i get
an error
The string was not recognized as a valid DateTime. There is a unknown word
starting at index 0.
any ideas
 
G

Guest

Pat,

This error is related to date parsing. You are trying to parse string, which
has invalid format regarding to current locale setting. There are several
ways to resolve this problem.
- Assign appropriate locale to current thread
System.Threading.Thread.CurrentThread.CurrentCulture =
new System.Globalization.CultureInfo("en-GB");
You can do it in application config as well.
- Parse date using DateTime.ParseExact method
DateTime datDate = DateTime.ParseExact(strDate, “DD/MM/YYYYâ€, null);

Hope this helps
 
P

Pat

Dziekuje
Patrick

Milosz Skalecki said:
Pat,

This error is related to date parsing. You are trying to parse string, which
has invalid format regarding to current locale setting. There are several
ways to resolve this problem.
- Assign appropriate locale to current thread
System.Threading.Thread.CurrentThread.CurrentCulture =
new System.Globalization.CultureInfo("en-GB");
You can do it in application config as well.
- Parse date using DateTime.ParseExact method
DateTime datDate = DateTime.ParseExact(strDate, "DD/MM/YYYY", null);

Hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top