By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,766 Members | 1,295 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,766 IT Pros & Developers. It's quick & easy.

Sql server date question {C#}

P: 153
I am string dates in DateTime format by two methods.

One in which i use DateTime.Now and other in which i manually create a DateTime object and fill the day,yeay,month etc.

During debugging DateTime.Now shows
'2/14/2009 11:28:44 AM'

And in manualy created DateTime object it shows
'2/14/0009 11:50:39 AM'

Both are exactly same ! (some diff due to diff times of degugging)

But when I use DateTime.Now it works fine and when I use the other it shows this error
(The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
The statement has been terminated.)

Feb 14 '09 #1
Share this Question
Share on Google+
2 Replies

P: 153
Ok i found where the problem is

INSERT INTO [CMS].[dbo].[Call_Data]( [Ext_Number],[Trunk_Number],[Cost],[Pin],[Account],[Called_Number],[Duration],[Description],[Call_Date] ) VALUES ('111','1',20,' ',' ','351',2,'Success','2/14/0009 12:01:02 PM' )

INSERT INTO [CMS].[dbo].[Call_Data]( [Ext_Number],[Trunk_Number],[Cost],[Pin],[Account],[Called_Number],[Duration],[Description],[Call_Date] ) VALUES ('111','1',20,' ',' ','351',2,'Success','2/14/2009 12:06:40 PM' )

See the bold date part.
When i fill it to datetime it gets filled as 00009.
I fill it as argument in DateTime Constructor (...,09,...)
How to solve this ?
How would i solve this ?
Feb 14 '09 #2

Expert 2.5K+
P: 2,878
Read this and this

-- CK
Feb 14 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.