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
How to Find Fifth Highest Salary in a Single Query in SQL Server
SQL Query - Delete Duplicates If More Than 3 Dups
Replace Unicode Characters in T-Sql
Bigquery SQL: Average, Geometric Mean, Remove Outliers, Median
Choose As400 Query Records Directly from Excel
Query a Table and a Column Name Stored in a Table
Returning the Value of Identity Column After Insertion in Oracle
Join Tables on Nearest Date in the Past, in MySQL
Select Single Row from Child Table for Each Row in Parent Table
Unpivot on an Indeterminate Number of Columns
Local Collection Types Not Allowed in SQL Statements
Good Database and Structure to Store Synonyms
How to Make Lag() Ignore Nulls in SQL Server
Cascade Delete in Many-To-Many Self-Reference Table
How to Calculate Moving Sum with Reset Based on Condition in Teradata SQL