I am trying to concatenate the CreateDate
and CreateTS
columns to make one Timestamp that contains the date and time.
Right now the only solution I reached is this:
SELECT
TO_TIMESTAMP(
to_char(COALESCE("UpdateDate","CreateDate",'1970-01-01'), 'yyyy-mm-dd') || ' '||
SUBSTRING (lpad(COALESCE("UpdateTS","CreateTS",0),6,'0'),0,2) || ':'||
SUBSTRING (lpad(COALESCE("UpdateTS","CreateTS",0),6,'0'),3,2)|| ':'||
SUBSTRING (lpad(COALESCE("UpdateTS","CreateTS",0),6,'0'),5,2), 'YYYY-MM-DD HH24:MI:SS'
) AS update_create
FROM OCRD
I found out that with UpdateTime
column this code isn't working.
The big problem is that the date and time are distinct columns, and also it saves the time in different formats:
- 8 : it's 00:08:00 and not 00:00:08
- 223 : it's 22:30:00 and not 00:02:23
- 16321 : it's 01:63:21
Is there any already defined function to concatenate the date and time to get the real timestamp of the create/update?
thanks