cancel
Showing results for 
Search instead for 
Did you mean: 

INSERT a TIMESTAMP value

Former Member
0 Kudos
12,779

I am trying to retrieve a timestamp value, set that value to a DateTime variable, then Insert that timestamp back into a different table, everything I have tried has not worked for me so far.

UPDATE

SET change_dttm = TO_TIMESTAMP('6/7/1991 08:18:15', 'YYYY-MM-DD HH24:MI:SS') WHERE table_name = '<some table="">';

or

UPDATE

SET change_dttm = '6/7/1991 08:18:15' WHERE table_name = '<some table="">';

Thanks in advance for any help

Accepted Solutions (1)

Accepted Solutions (1)

VolkerBarth
Contributor
0 Kudos

Are you using ORACLE as the database system?

AFAIK, TO_TIMESTAMP is not a SQL Anywhere function.

With SQL Anyhwere, you can usually insert timestamp values directly as string literals - with implicit conversion, such as:

create table T_Test (pk int primary key, dt timestamp not null);
insert T_Test values (1, '2011-06-08 16:20:12.345678');
select * from T_Test;

When using different formats (like DD/MM/YYYY...), you will have to adapt the date_order option, possibly only temporarily:

insert T_Test values (2, '08/06/2011 16:20:12.345678'); -- fails with SQLCODE -157
set temporary option date_order = 'DMY';
insert T_Test values (2, '08/06/2011 16:20:12.345678'); -- works now
select * from T_Test;

Answers (0)