471,082 Members | 722 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,082 software developers and data experts.

SQL-ASP.NET datetime format problem ???

Hi ,
I have two Sql Server 2000 on seperate machines ,
First one accepts datetime format like ("dd.MM.yyyy hh:mm:ss")
And Second one accepts datetime format like ("MM.dd.yyyy hh:mm:ss")

1- Date formats are different because of SQL Collation?
2- Do regional Settings affect Sql date format?
3- (Important) When inserting a datetime into first server there is no
problem (15.12.2000 12:12:12) , but when I insert into second server (if day
is greater then 12 ) the following error occurs
"The conversion of a char data type to a datetime data type resulted in an
out-of-range datetime value"
So each time I format the datetime value to ("dd.MM.yyyy hh:mm:ss") when
inserting into second server,

I don't want to change date Format each time manuelly
So I think ,I need to know that in code behind Which date format SQL server
accept?
My app is ASP.NET with VB.NET

I use System.DateTime , should I use System.Data.SqlTypes.SqlDateTime ?
Any idea ?

Best regards...


Dec 16 '05 #1
1 2722
Always format dates to include the month as a NAME it makes some many
problems like this go away!

eg "dd MMM yyyy hh.mm.ss" or "MMM dd yyyy hh.mm.ss"

sql server( and most other databases) then has enough to go on when in
converts the string to a datetime.

i assume you are building the sql string in code, if you use dataadapters
and parameters then dot net will do the culture stuff for you.
"Ugur Ekinci" <ug**@argeset.com> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
Hi ,
I have two Sql Server 2000 on seperate machines ,
First one accepts datetime format like ("dd.MM.yyyy hh:mm:ss")
And Second one accepts datetime format like ("MM.dd.yyyy hh:mm:ss")

1- Date formats are different because of SQL Collation?
2- Do regional Settings affect Sql date format?
3- (Important) When inserting a datetime into first server there is no
problem (15.12.2000 12:12:12) , but when I insert into second server (if
day is greater then 12 ) the following error occurs
"The conversion of a char data type to a datetime data type resulted in an
out-of-range datetime value"
So each time I format the datetime value to ("dd.MM.yyyy hh:mm:ss") when
inserting into second server,

I don't want to change date Format each time manuelly
So I think ,I need to know that in code behind Which date format SQL
server accept?
My app is ASP.NET with VB.NET

I use System.DateTime , should I use System.Data.SqlTypes.SqlDateTime ?
Any idea ?

Best regards...


Dec 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Peter | last post: by
9 posts views Thread by Grim Reaper | last post: by
6 posts views Thread by Fuzzydave | last post: by
reply views Thread by leo001 | last post: by

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.