INSERT a datetime using convert

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hallo
I have an SQLCE database into which I want to insert a datetim

INSERT INTO ADR_ADDRESS (Last_Edited) VALUES ( Convert('01-FEB-2004 11:12:22','dd-mon-yyyy hh:mi:si')

The table was defined wit
CREATE TABLE ADR_ADDRESS (
Address_ID integer Primary Key NOT NULL
,Last_Edited datetime

Unfortunately this does not work, can anyone see what is wrong

Thanks..

Nigel..
 
Hi Nigel,

I think that that is not right use of CONVERT function.
Try with: Convert(datetime, '01 FEB 2004 11:12:22:000') or Convert(datetime,
'01 FEB 2004 11:12:22:000', style)
See Sql server on CONVERT for more help.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Nigel Findlater said:
Hallo,
I have an SQLCE database into which I want to insert a datetime

INSERT INTO ADR_ADDRESS (Last_Edited) VALUES ( Convert('01-FEB-2004
11:12:22','dd-mon-yyyy hh:mi:si'))
 
Thanks This did the trick..

By the way, do you know how to create a table with an auto increment number on SQL CE

I tried CREATE TABLE ADR_ADDRESS ( Address_ID counter Primary Key NOT NULL

but this did not work. I am not sure if I need to make a trigger or if SQLCE has a nice way of handling it..

Nigel...
 
Nigel Findlater said:
Thanks This did the trick...

By the way, do you know how to create a table with an auto increment
number on SQL CE?

I tried CREATE TABLE ADR_ADDRESS ( Address_ID counter Primary Key NOT
NULL )

but this did not work. I am not sure if I need to make a trigger or
if SQLCE has a nice way of handling it...

I use:

CREATE TABLE Foo (ID int IDENTITY PRIMARY KEY ...)
 
Back
Top