Aditya
Aditya

Reputation: 1043

Update Date to Next Month Oracle

I am writing an UPDATE statement to Update Table set Column = the last day of next month.

I tried something like this but doesn't seem to work.

Update MyTable SET MyColoumn = To_Date(((Month From Current_Timestamp) +1)'-31-2015' , 'MM-DD-YYYY');

Upvotes: 1

Views: 2706

Answers (2)

David Faber
David Faber

Reputation: 12486

Another alternative would be:

UPDATE mytable
   SET mycolumn = TRUNC( ADD_MONTHS( SYSDATE, 2 ), 'MONTH' ) - 1;

Upvotes: 1

Justin Cave
Justin Cave

Reputation: 231651

UPDATE myTable
   SET myColumn = last_day( add_months( sysdate, 1 ))

should work. add_months adds 1 month to the current date. last_day gives you the last day of the month.

Upvotes: 9

Related Questions