My data set contains separate year, month, day, hour, minute, and second columns as following that are separated by space:
+-------------------+
|2007|09|28|21|14|06|
|2007|09|28|21|14|06|
|2007|09|28|21|14|06|
|2007|09|28|21|14|06|
|2007|09|28|21|14|06|
+-------------------+
I wanted to integrate them as a single column under timestamp data-type.
I have created a new column in timestamp data-type and update the column by following code:
Update s2
set dt = year || '-' || month || '-' || day
|| ' ' || hour || ':' || min || ':' || second
But I faced by following error:
ERROR: column "dt" is of type timestamp without time zone but expression is of type text
LINE 1: Update temp set dt= year || '-' || month || '-' || day ||...
^
HINT: You will need to rewrite or cast the expression.
********** Error **********
ERROR: column "dt" is of type timestamp without time zone but expression is of type text
SQL state: 42804
Hint: You will need to rewrite or cast the expression.
Character: 22
Moreover, I can preform the integration by varchar data-type.
The result of the expression
is not a timestamp but a plain text. The error message simply tells you, that the type
textis not appropriate to the type of thedtcolumn.You must cast the complete expression like this: