Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Date Problem

Author  Topic 

Hoffmann
Starting Member

6 Posts

Posted - 2009-10-05 : 15:13:25
I'm getting a problem that is driving me nuts.

I have gotta import several information through SQL server but every time I do that EVERY datetime field is set to 1905-xx-xx.

that's how I am doing:

INSERT INTO clientes (id_cliente, razaosocial, tipocliente, datacadastro, datafundacao, cep, endereco, bairro, cidade, uf, telefone1, telefone2, email, site, cnpj, dataultimacompra, dataprevisaocompra, turismo, fretamento, escolar, urbanoalternativo, urbanoseletivo)

VALUES (1,'XXX BELO HORIZONTE LTDA',1,2008-5-2,2005-12-12,'30880-000','RUA FLORA, 44','COQUEIROS','BELO HORIZONTE','MG','31 3222 7766','','','','12548632057852',2007-1-9,2008-2,'','1','1','','');

and I get something like this:

1 XXX BELO HORIZONTE LTDA 1 1905-06-25 00:00:00.000 1905-06-05 00:00:00.000 30880-000 RUA FLORA, 44 NULL COQUEIROS BELO HORIZONTE MG NULL 31 3222 7766 NULL NULL NULL NULL 12548632057852 NULL 1905-06-21 00:00:00.000 1905-06-30 00:00:00.000 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 0 1 1 0 0

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-10-05 : 15:24:12
Dates need single quotes just like text.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

Hoffmann
Starting Member

6 Posts

Posted - 2009-10-05 : 15:51:42
but then I got this problem:

Mensagem 241, Nível 16, Estado 1, Linha 5
Conversion failed when converting datetime from character string.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-10-05 : 16:38:04
VALUES (1,'XXX BELO HORIZONTE LTDA',1,'2008-5-2','2005-12-12','30880-000','RUA FLORA, 44','COQUEIROS','BELO HORIZONTE','MG','31 3222 7766','','','','12548632057852','2007-1-9','2008-2','','1','1','','');


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

Hoffmann
Starting Member

6 Posts

Posted - 2009-10-05 : 17:22:45
I did it and didn't work....got the error above:

Conversion failed when converting datetime from character string. Oo

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-10-06 : 03:23:50
'2008-2' probalby cannot be interpreted as a date.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-10-06 : 03:47:22
and 2008-2 should be 2008-02-01

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Hoffmann
Starting Member

6 Posts

Posted - 2009-10-06 : 10:57:26
yeah, that was the problem, thank you very much ^^
Go to Top of Page
   

- Advertisement -