Sripaul
Sripaul

Reputation: 2235

Replacing month in TimeStamp from Date

I am new to Oracle DB and have a situation in hand.
I have two tables.

Table1 [ ID, MY_DATE ]
Table2 [ ID, MY_TIMESTAMP]

I need to pick the month alone from Table1.MY_DATE and replace the corresponding month at Table2.MY_TIMESTAMP.
Both Table1 and Table2 are joined by ID.

How do I pick the month alone from a Date column and replace month alone in a TimeStamp field.
Can anyone please help?

Upvotes: 0

Views: 762

Answers (1)

Rohan
Rohan

Reputation: 2030

UPDATE SO_BUFFER_TABLE_13 BT2 SET BT2.MY_TIMESTAMP = TO_DATE((TO_CHAR(BT2.MY_TIMESTAMP, 'DD') || '/' || (SELECT TO_CHAR(BT1.MY_DATE, 'MM') FROM SO_BUFFER_TABLE_12 BT1 WHERE BT1.ID = BT2.ID) || '/' || TO_CHAR(BT2.MY_TIMESTAMP, 'YYYY HH:MI:SS AM')), 'DD/MM/YYYY HH:MI:SS AM')

Hope is helps

Upvotes: 2

Related Questions