cancel
Showing results for 
Search instead for 
Did you mean: 

Convert Column from date to timestamp

Former Member
0 Kudos

Hi,

is there a way to convert a database column of type date into timestamp?

It does not work with the SqlStudio. A Date can only be converted into varchar. And I get an error with the statement 'alter table xytab modify xycol timestamp', because of an error (Invalid date format:ISO).

Can anyone please help me?

Many thanks in advance, Oliver.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

a conversion can be done using the function TIMESTAMP (a,b), where a has to be the date-value and b has to be some time-value.

There is no implicit conversion during alter table modify from date to timestamp.

Therefore you will have to

rename date-column to xyz

alter table add wanted-column-name TIMESTAMP

update wanted-column-name = timestamp(xyz, <some time-value you like>)

alter table drop xyz

And as you are using ISO-time-format you should keep in mind, that the used timevalue has to be specified according to this:

'HH:MM:SS' example: '14:30:08'

Good luck,

Elke

Answers (1)

Answers (1)

Former Member
0 Kudos

That's it.

Many many thanks for the quick response.

Bye Oliver