Add 2 Months to Current Timestamp

Oracle - Add days/months to a TIMESTAMP WITH TIME ZONE field

When you do DATED = DATED + 2, then DATED is implicitly converted to a DATE value (which does not have any time zone information) and then converted back to TIMESTAMP WITH TIME ZONE value using your current session time zone settings.

Try

UPDATE MY_TABLE SET DATED = DATED + INTERVAL '2' DAY WHERE ID = 1165;

or

UPDATE MY_TABLE SET DATED = DATED + 2 * INTERVAL '1' DAY WHERE ID = 1165;

or

UPDATE MY_TABLE SET DATED = DATED + NUMTODSINTERVAL(2, 'day') WHERE ID = 1165;

In order to add 2 months you can use

UPDATE MY_TABLE SET DATED = DATED + INTERVAL '2' MONTH WHERE ID = 1165;

resp. NUMTOYMINTERVAL(2, 'MONTH'), for example.

How to properly add 1 month to current date in moment.js

var currentDate = moment('2015-10-30');
var futureMonth = moment(currentDate).add(1, 'M');
var futureMonthEnd = moment(futureMonth).endOf('month');

if(currentDate.date() != futureMonth.date() && futureMonth.isSame(futureMonthEnd.format('YYYY-MM-DD'))) {
futureMonth = futureMonth.add(1, 'd');
}

console.log(currentDate);
console.log(futureMonth);

DEMO

EDIT

moment.addRealMonth = function addRealMonth(d) {
var fm = moment(d).add(1, 'M');
var fmEnd = moment(fm).endOf('month');
return d.date() != fm.date() && fm.isSame(fmEnd.format('YYYY-MM-DD')) ? fm.add(1, 'd') : fm;
}

var nextMonth = moment.addRealMonth(moment());

DEMO

How to add months to a date in JavaScript?

Corrected as of 25.06.2019:

var newDate = new Date(date.setMonth(date.getMonth()+8));

Old
From here:

var jan312009 = new Date(2009, 0, 31);
var eightMonthsFromJan312009 = jan312009.setMonth(jan312009.getMonth()+8);

Adding months to timestamp in PHP

Since you are using the current timestamp, you can omit the $currentDate variable altogether and it should make the notice go away too.

    $bought_months = 6;
$expiring = strtotime('+'.$bought_months.' month');

Add months to a date in Pandas

You could use pd.DateOffset

In [1756]: df.date + pd.DateOffset(months=plus_month_period)
Out[1756]:
0 2017-01-11
1 2017-02-01
Name: date, dtype: datetime64[ns]

Another way using pd.offsets.MonthOffset

In [1785]: df.date + pd.offsets.MonthOffset(plus_month_period)
Out[1785]:
0 2016-10-14
1 2016-11-04
Name: date, dtype: datetime64[ns]

Details

In [1757]: df
Out[1757]:
date
0 2016-10-11
1 2016-11-01

In [1758]: plus_month_period
Out[1758]: 3

Add a month in timestamp in each iteration

Are you looking for something like:

strtotime("+1 month", $myTimestamp); 

http://us2.php.net/strtotime



Related Topics



Leave a reply



Submit