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

asked 08 Jun '11, 11:36

JustinWolbeck's gravatar image

JustinWolbeck
6112
accept rate: 0%


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;
permanent link

answered 08 Jun '11, 11:48

Volker%20Barth's gravatar image

Volker Barth
40.1k361549819
accept rate: 34%

edited 08 Jun '11, 11:50

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×34
×22

question asked: 08 Jun '11, 11:36

question was seen: 12,409 times

last updated: 08 Jun '11, 11:50