p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

asp_databases thread: Date is getting inserted into DB incorrectly


Message #1 by ckoski@w... on Wed, 26 Jul 2000 16:42:16 -0400
I've come across an issue with SQL Server 6.5 where I add a new record into

a table through ADO using the Command object, parameters, and a SQL Server

Stored procedure...  when I send this date through (8/2/2000), I get this

date back stored in the database (2/8/2000).....  can anyone point out to me

why this is occuring?





**************************************************

Cory Koski

Web Programmer

Wabang Creative Technology and TBSource.com

Brainbench e-certified Master ASP programmer

(xxx) xxx-xxxx  ext. 41







Message #2 by Hari Yellina <hyellina@k...> on Thu, 27 Jul 2000 04:59:31 -0500
Date is stored in sql in that format. So, it  gives you that way. How ever

you try to store in the Database. It stores in its own format. While

retriving it retrives in the databse format

HK Yellina,

Kanbay Software (India) Pvt. Ltd.

A-1, Technology Park,

MIDC,

Talwade,

Pune,

Maharastra.

412114

ph 091-020-7691100 ext-440



> ----------

> From: 	ckoski

> Reply To: 	ASP Databases

> Sent: 	Wednesday, July 26, 2000 3:42 PM

> To: 	ASP Databases

> Subject: 	[asp_databases] Date is getting inserted into DB incorrectly

> 

> I've come across an issue with SQL Server 6.5 where I add a new record

> into

> a table through ADO using the Command object, parameters, and a SQL Server

> Stored procedure...  when I send this date through (8/2/2000), I get this

> date back stored in the database (2/8/2000).....  can anyone point out to

> me

> why this is occuring?

> 

> 

> **************************************************

> Cory Koski

> Web Programmer

> Wabang Creative Technology and TBSource.com

> Brainbench e-certified Master ASP programmer

> (xxx) xxx-xxxx  ext. 41

> 

> 

> 

Message #3 by "Fredrik Normen" <fredrik.normen@s...> on Thu, 27 Jul 2000 11:35:29
Mybe you have configure you SQL server to use a dateformat like that.

And ASP will display in that format your server is using.



For exampel. I use Swedish format in my database but when I get the data 

from SQL Server I have it in English format.



Instead of changing the time/date format on the server I use LCID ( Locale 

ID ).



Like this in Global.asa on Session_Start



Session.LCID = 1056



Now all time/date format are displayed after Swedish format.



Hope this will help you..



/Fredrik Normen

Message #4 by "Ken Schaefer" <ken.s@a...> on Fri, 28 Jul 2000 10:54:29 +1000
The could be several issues here.

Check the Regional Settings and make sure that the locale you want to use is

the one set to be used as the System Default Locale (there's a little tick

box on the first tab of the Regional Settings Control Panel).



Next (and this is a problem with Access, don't know about SQL Server v6.5),

even if your default locale settings have a dates set as dd/mm/yyyy Access

will take any date that can be construed as mm/dd/yyyy and put it in the

database as such. Any date that can't be construed as mm/dd/yyyy (eg

30/6/2000) will be put in as the correct dd/mm/yyyy



The underlying reason for this odd behaviour is that Access doesn't store

dates in the format you specify in the Regiona Settings, it only uses those

for display purposes (eg when you open a table to manually add data).



The best solution, is this is the case, is to insert data in yyyy/mm/dd

format, since even the Americans are not perverse enough to come up with a

yyyy/dd/mm format to break this.



Cheers

Ken





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

From: "Cory Koski" <ckoski@w...>

To: "ASP Databases" <asp_databases@p...>

Sent: Thursday, July 27, 2000 6:42 AM

Subject: [asp_databases] Date is getting inserted into DB incorrectly





> I've come across an issue with SQL Server 6.5 where I add a new record

into

> a table through ADO using the Command object, parameters, and a SQL Server

> Stored procedure...  when I send this date through (8/2/2000), I get this

> date back stored in the database (2/8/2000).....  can anyone point out to

me

> why this is occuring?






  Return to Index