473,472 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

smalldatetime problem

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
Nov 19 '05 #1
3 2065
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.CurrentCultu re =
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

--
Milosz Skalecki
MCP, MCAD
"Pat" wrote:
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

Nov 19 '05 #2
Pat
Dziekuje
Patrick

"Milosz Skalecki" <Mi************@discussions.microsoft.com> wrote in
message news:83**********************************@microsof t.com...
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.CurrentCultu re =
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

--
Milosz Skalecki
MCP, MCAD
"Pat" wrote:
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

Nov 19 '05 #3
Nie ma sprawy :D

BTW, you can you click 'yes' at the bottom if answer helped you.

--
Milosz Skalecki
MCP, MCAD
"Pat" wrote:
Dziekuje
Patrick

"Milosz Skalecki" <Mi************@discussions.microsoft.com> wrote in
message news:83**********************************@microsof t.com...
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.CurrentCultu re =
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

--
Milosz Skalecki
MCP, MCAD
"Pat" wrote:
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


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joey Martin | last post by:
How do I convert an nvarchar field to smalldatetime format? My nvarcharfield (saledatetext) is in the format YYYY-MM-DD. I want to convert is to smalldatetime (field: saledate) Thanks for...
2
by: Joey Martin | last post by:
Please help. I have a ms sql table called data. Two fields, saledate(smalldatetime),saledatetext(nvarchar) I have dates (ex. 05/04/05) in the saledatetext, but I need this converted into...
7
by: Marc Pelletier | last post by:
Hello, I have a table with a Day field, defined as smalldatetime. I am filling it from a CSharp application with the following code: DataRow r = dtStaDays.NewRow(); r= station_ID; r =...
7
by: Bostonasian | last post by:
I have a table that contains transactional data. Such as site view by whom, when, which template, etc, etc... Everytime when I pulled the report, hh:mm:ss never matters. Only breakdown by dates,...
2
by: Marc Pelletier | last post by:
Hello all, I have a library of datetime routines that make things simpler for me. Before I discovered DateTime.MinValue I had a function that looked like public static DateTime DayZero { get {...
2
by: .Net Sports | last post by:
I'm using these to assign a variable to a smalldatetime object in sql server: dim todnews = DateTime.Today.ToString ( "d" ) 'connection string to server is on this line Dim strSQL2 as string...
5
by: Dimitri Furman | last post by:
This looks like a bug - hopefully somebody can explain what is actually happening. Using SQL Server 2000 SP4. Here's a repro script with comments: /* repro table */ CREATE TABLE dbo.T ( ID...
6
by: SQL Server | last post by:
I've been working this for a while. Kind of new to SQL Server functions and not seeing what I am doing wrong. I have this function CREATE FUNCTION dbo.test (@Group varchar(50)) RETURNS...
4
dcharnigo
by: dcharnigo | last post by:
I am converting a varchar(10) field to a smalldatetime in a stored procedure but have run into a problem. Some of the rows contain an invalid date. varchar(10) format is mm/dd/yyyy some rows are...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.