TimeStamp - Add Months
Dear All,
I have the requirement to calculate an opportunity 'contract end date' as follows:
User Populates:
Contract Start Date = 01/11/2008
Contract Duration (Months) = 4
Calculation Required:
Contract End Date = 01/03/2009
Any suggestions?
A simple calculation "[<ContractStartDate>] + [<ContractDuration>]" gives me the correct result in days, i'm just not sure how to add months instead?
Thanks
Innoveer
Edited by: Innoveer on Oct 31, 2008 4:14 AM
Edited by: Innoveer on Oct 31, 2008 4:47 AM
Hi !
To do this calculation, your field Contract Duration must be a numeric field
Two things to do:
To calculate this field after creating an opportunity, use the field default value (Contract Start Date + Contract Duration).
To recalculate it after a modification of the Contract Start Date or on the Contract Duration, you'll need to create a WorkFlow rule :
Record type : Opportunity
Trigger event : Before saving modifications
Condition : [<Contract Start Date>]<>PRE('Contract Start Date') OR [<Contract Duration>]<>PRE('Contract Duration')
Action : Update value Contract End Date with value Contract Start Date + Contract Duration and overwrite existing value.
Hope this will help, feel free to ask more !
Max
Similar Messages
-
Trying to add month with a Date
Hi All,
I am trying to add month with a date. it will take the earlier month and add one month . Here is my code
declare @CollectionDate date='10-30-2014'
select @CollectionDate
;WITH CTemp AS (
SELECT TransactionDate=CAST(@CollectionDate AS DATE) ,RemainingTransaction=1
UNION all
SELECT TransactionDate=DATEADD(MONTH,1,CONVERT(date, CONVERT(varchar(4), YEAR(TransactionDate))
+'-'+CONVERT(varchar(2),MONTH(TransactionDate))
+'-'+ CONVERT(varchar(2),DATEPART(day, @CollectionDate)))),
RemainingTransaction+1
FROM CTemp
WHERE RemainingTransaction < 9
select * from CTemp
When I am giving date 10-28-2014 then it is working fine. But when the date is 10-31-2014 then it shows me the error
Msg 241, Level 16, State 1, Line 3
Conversion failed when converting date and/or time from character string.
I can undestand it is for the month of February but how do I overcome it?
Can anyone help me on this?
Thanks in advance!!
Niladri BiswasTry the below:
--To find the last day of the month, use the below:
declare @CollectionDate date='10-30-2014'
select @CollectionDate
;WITH CTemp AS (
SELECT TransactionDate=CAST(@CollectionDate AS DATE) ,RemainingTransaction=1
UNION all
SELECT TransactionDate=cast(DATEADD(day,-1,DATEADD(month,MONTH(Transactiondate)-1,DATEADD(year,YEAR(TransactionDate)-1900,0))) as DATE),
RemainingTransaction+1
FROM CTemp
WHERE RemainingTransaction < 9
select * from CTemp
--Just to add a month, use the below
declare @CollectionDate date='10-30-2014'
select @CollectionDate
;WITH CTemp AS (
SELECT TransactionDate=CAST(@CollectionDate AS DATE) ,RemainingTransaction=1
UNION all
SELECT TransactionDate=DATEADD(month,-1,TransactionDate),
RemainingTransaction+1
FROM CTemp
WHERE RemainingTransaction < 9
select * from CTemp
EDIT: You may change -1 to 1 if you want the future months.(I am bit confused whether you are looking for previous months or future months.) -
Hi All,
I have an query.
query:
date format output
11/06/2014 11/06/2014 + 2 months= 11/08/2014
10/05/2014 10/05/2014 + 2 months= 10/07/2014
i am stuck due to there are 28/29/30/31 days are in months. so i can not proceed for add days.
Thanks in advance..
RanjeetHi Ranjeet,
Please refer below thread to do in universe-
Reg; Webi Reporting Queries
However, If you want to do at report level follow below-
Create Variables-
MonthNum=If Mod(MonthNumberOfYear(<Cal Date>)+2 ,12)=0 Then 12 Else Mod(MonthNumberOfYear(<Cal Date>)+2 ,12)
TargetMon=MonthNumberOfYear(RelativeDate(<Cal Date> ,(DayNumberOfMonth(LastDayOfMonth(<Cal Date>))+DayNumberOfMonth(LastDayOfMonth(LastDayOfMonth(<Cal Date>)+1)))))
Intermediate Date1=RelativeDate(<Cal Date> ,(DayNumberOfMonth(LastDayOfMonth(<Cal Date>))+DayNumberOfMonth(LastDayOfMonth(LastDayOfMonth(<Cal Date>)+1))))
Intermediate Date2=LastDayOfMonth(<Intermediate Date1>-5)
TargetDate= If <TargetMon>-<MonthNum>=0 Then <Intermediate Date1> Else <Intermediate Date2>
Use TargetDate variable in your report column.
Replace <Cal Date> to your date column in above formula. Let us know if it works.
Thanks,
Anuj -
Add monthly updates patch to WDS
Hi Guys,
can you please help to figure out how I add to packages of the monthly windows udpates in the WDS?
you can assist me also at [email protected]The task sequence it's for MDT not for WDS.
If you want necessary use wds, you can try use an answer File. This file must be attached to wim file.
You can add on the answer file, the execution of a vbs or powershell file (oobe option 7). The script contains silent installation lines for patches.
I do not recommend this solution, however, it is much easier to integrate or monthly patches in the image is best to install mdt -
To extend SAP user date and to add months to the current date
Hi All,
I need to extent the user date in SAP based on one condition.
If the condition is true extend the date by 12 monthd if false 6 months from the current date.
Can i have the FM for user date extentions and FM for getting the date.
Thanks,
Chandu.Hi ,
You can use this FM for exteding the date.
CALL FUNCTION 'BAPI_USER_CHANGE'
EXPORTING
username = us_username
logondata = e_bapilogond
logondatax = e_bapilogondx
TABLES
return = i_return.
u need to pass date and correspoing flag also.
For extension of the date by months u can use this FM.
CALL FUNCTION 'MONTH_PLUS_DETERMINE'
EXPORTING
months = 6 or 12 ( depending up on ur logic)
olddate = sy-datum
IMPORTING
newdate = us_expdate.
Thanks and regards.
Sham -
Family budget add monthly sheet and auto populate master sheet with graphs
I would like to create a monthly budget template that i can link to a master document that will graph what we have paid and compare it to previous months. I may not have the correct vocabulary for this because i am pretty new to using equasions and linking documents.
q,
A Numbers Document, a file, can't communicate with another Numbers Document, file, without using scripts. You may keep the Master and the Monthly detail Sheets in the same document to accomplish your task.
If your monthy sheet sizes are modest, you should have no capacity or speed issues.
Jerry -
Add months do Presentation variable
I do have a Pres.Variable in a date format - like: DD/MM/YYYY. I need to use it as a filter... when using @{VAR} is ok...
Now I need to filter another column but using @{VAR} next month... Tried to use TIMESTAMPADD with @{VAR} but no success... maybe TIMESTAMPADD just use dates like YYYY/MM/DD ?
Tried to use a couple of CAST functions but no success either...
I´d appreciate any help.
txs
AntonioTry something like below. Good results when you use default value.
date '@{D}{01/21/2010}'
For month try to tweak as I mentioned in your other post ie. Time."Month" = '@{M1}' -
How to add month to dashboard header?
Hi Experts,
we have calmonth coming from a cube and that is supplied to a query and this query is the source for the dashboard. i need to add calmonth to dashboard header ? please give ur inputs..
we are broadcasting to portal with bex broadcaster settings.
points will be assigned.
ThanksYou can place rectangle in header section on master page which would be applied on sub pages and then fill rectangle with color.
If you are after a specific color then simply use color code and fill.
Thanks,
Sanjit -
Logic to compare date with standard timestamp
Hi Experts,
I want to retrieve the data which is "n" moths old.
To compare that I want use only SYSDATE without timestamp.
I want to use standard timestamp '23:59:59' along with SYSDATE.
The condition should be as below.
UPDATE_DATE <= ADD_MONTHS(15/01/2013 23:59:59,-3)
UPDATE_DATE <= ADD_MOTHS(30/01/2013 23:59:59,-4)
UPDATE_DATE<=ADD_MONTHS(sysdate||' '||'23:59:59',-3);Please help me how to implement it.
Thanks in advance.973205 wrote:
Thanks for your reply.
Your query is not meeting my requirement.
It just adding one day after it's adding months.
TRUNC(sysdate) means it will truncate timestamp.
I want to use standard timestamp along with sysdate.
TRUNC(sysdate)||' '||'23:59:59' after that I want to add months.
What you are trying to do is to concatenate a character string to a DATE value - which will not work and is not logical also..
This can be achieved as below - minus 1 second from trunc(sysdate+1)
select trunc(sysdate+1)-(1/(24*60*60)) dt
from dual;
DT
03-Feb-2013 23:59:59 Your requirement is to filter as UPDATE_DATE<=ADD_MONTHS(sysdate||' '||'23:59:59',-3);
This can be done as
UPDATE_DATE<=ADD_MONTHS(trunc(sysdate+1)-(1/(24*60*60)),-3);The same thing can be achieved by replacing "<=" with "<" as
UPDATE_DATE<ADD_MONTHS(trunc(sysdate+1),-3);Edited by: jeneesh on Feb 3, 2013 12:39 PM -
Average monthly income in Numbers 3
I use numbers to keep the books and I am trying to get the total for each month automatically. To simplify things, let's assume column A contains the date and B the amount. Out of this, I am trying to return the total for each mont in a separate table. I would expect it to say APR: 200, JUN: 400, JUL 150 and so on.
A B
02 APR 250
05 APR -50
03 JUN 100
15 JUN 300
08 JUL 150
Any thoughts on how to do this?
Thanks in advance.Hi Christian,
Here we go. This is not an automatic timestamp, but it goes some way to answer your question:
to fill the A column with the current date when inputing something new into the B column?
Slight alteration, the amounts go into the C column:
This uses =NOW() in column A. The data format is Date & Time to display only the date part.
NOW() is not a timestamp; it insert the current Date & Time and continues to update.
To "freeze" it at an instant in time, select the cell, Copy, then Menu > Edit > Paste Formula Results. More on that later.
B2 contains this formula (and Fill Down):
=IF(LEN(C2)>0,MONTHNAME(MONTH(A2)),"")
If the length (LEN) of a cell in C is greater than 0 (the cell is not empty) then grab MONTH (a number) from A and convert it to the MONTHNAME
else insert "" (NULL).
B shows the month to fit SG's solution of using SUMIF to add monthly totals.
Save As Template.
In use, make an entry in column C:
The month name appears. Immediately "freeze" the cell in A (Copy, then Menu > Edit > Paste Formula Results) so it will no longer update. To be doubly sure, you may want to "freeze" the month in B at the same time. The rows below the entry are still free to update, waiting for the next entry and "freezing".
Your workflow is: if there is an entry in C, then A and B in that row must be frozen (select, command c, shift command v).
Regards,
Ian. -
Hi,
I have encountered a problem with generating a timestamp channel out of integer channels for years, months, days, hrs, min and sec. All these channels have been read from a binary file as eI32s. Now, I would like to genereate a timestamp from them in the order #YYYY.MM.DD hh:mm:ss but nothing I have tried works. Ideally, I do not want to loop through the channel values, much preferring to call a calculate function like:
Call Calculate("Ch(""[1]/date"")=DateSerial(Ch(""[1]/year""),Ch(""[1]/month""),Ch(""[1]/day""),""#YYYY.MM.DD"")",NULL,NULL,"")
Should I convert the integer channels I have to text? If so how does one do that? A command like: Call Calculate("Ch(""[1]/textyear"")=str(Ch(""[1]/intyear"")),NULL,NULL,"") doesn't work on channels.
Should I have read the values as strings from the binary channel with the plugin in the first place?
Is there a better way of generating a channel of time stamps bits of which are spread across other channels?
Thanks in advance.
Solved!
Go to Solution.Hi tspc,
I spoke too soon and/or withhout thinking deeply enough. Below you will find a DataPlugin which indeed uses the Channel.Factor property and a ProcessedChannel to combine only the hours, minutes, and seconds channels, but the date is not linear because the days per month and days per year vary:
Sub ReadStore(File)
Dim oBlock : Set oBlock = File.GetBinaryBlock()
oBlock.BlockWidth = 3424
Dim oChannelGroup : Set oChannelGroup = Root.ChannelGroups.Add(File.Info.FileName)
Dim oChannel0 : Set oChannel0 = oChannelGroup.Channels.AddProcessedChannel("DateTime", eR64, eAddProcessor)
Dim oChannel1 : Set oChannel1 = oBlock.Channels.Add("year", eI32) : oChannel1.Offset = 1900
Dim oChannel2 : Set oChannel2 = oBlock.Channels.Add("month", eI32)
Dim oChannel3 : Set oChannel3 = oBlock.Channels.Add("day", eI32)
Dim oChannel4 : Set oChannel4 = oBlock.Channels.Add("hrs", eI32) : oChannel4.Factor = 3600
Dim oChannel5 : Set oChannel5 = oBlock.Channels.Add("min", eI32) : oChannel5.Factor = 60
Dim oChannel6 : Set oChannel6 = oBlock.Channels.Add("sec", eI32)
Call oChannel0.Channels.Add(oChannel4)
Call oChannel0.Channels.Add(oChannel5)
Call oChannel0.Channels.Add(oChannel6)
oChannel0.Properties.Add "DisplayType", "Time"
Call oChannelGroup.Channels.AddDirectAccessChannel(oChannel1)
Call oChannelGroup.Channels.AddDirectAccessChannel(oChannel2)
Call oChannelGroup.Channels.AddDirectAccessChannel(oChannel3)
End Sub
You need to call this DataPlugin to load the data files and then run a channel calculation to turn the year, month, and day channels into a real number of elapsed seconds since 0 AD and add them to the time channel, like this:
Call Data.Root.Clear
DataFilePath = "C:\NICS\Discussion Forums\tspc\DataFile.abc"
Call DataFileLoad(DataFilePath, "tspc_abc")
Set Channels = Data.Root.ActiveChannelGroup.Channels
Symbols = Array("dt", "yr", "mon", "day")
ChanRefs = Array(Channels(1), Channels(2), Channels(3), Channels(4))
Equation = "dt = dt + TTR(yr & ""/"" & Right(""00"" & mon, 2) & ""/"" & Right(""00"" & day, 2), ""#yyyy/mm/dd"")"
Call Calculate(Equation, Symbols, ChanRefs)
Call Channels.Remove(Channels(4).Name)
Call Channels.Remove(Channels(3).Name)
Call Channels.Remove(Channels(2).Name)
Brad Turpin
DIAdem Product Support Engineer
National Instruments -
1st & last day of month based on month selected
Hi All,
I am an infant in BO. I want to create a variable in which I need to compare Order Creation Date with First Day of Month and Last Day of Month.
I have gone through the posts here regarding this, I found huge no of posts on calculating the 1st & last day of month based on a date value. But,
I don't have any date objects in the universe level, instead I have only Month Name/Month Number objects in the universe level (as it is a monthly report)
So, How to create 1st day & last day of month based on the month selected.
That is, If I run the report for FEB 2011 (Prompt values), I need the outputs as 01/02/2011 & 28/02/2011 as my 1st & last date values respectively.
I am working on BOXI R 3.1
Thanks in Advance,
MitchHi
Create a variables and write a formula like
Also add Month number Object in query level
Var_Month
=userresponse("Enter Month")
Var_A
"01/"MonthNumberObj+Right(var_Month;4)
var_First date
Todate(var_A;"dd/MM/yyyy")
var_lastdate
=lastdayofmonth(var_Firstdate)
Note: check the default format for date according to ur database like MM/dd/yy or something like that . and add in the var_firstdate
regards
Sunil -
Is there a completely reliable method of adding months to a date in ABAP?
Does anyone know of a completely reliable and consistent ABAP function module that can be used to add months to a date. One that will always get the correct last day of the month when requested to add 1 month to the last day of the previous month. Something as reliable as using the ADD_MONTHS function in Oracle SQL. I don't want to use any of the specific 'get last day of the month' function modules since the start date may not necessarily be the last day of a month.
In the past I have trusted the following. Now they have betrayed me.
MONTHS_PLUS_DETERMINE
Correctly provides 28.02.09 when adding 1 months to 31.01.09.
Incorrectly gives me 28.03.09 instead of 31.03.09 when adding 1 month to 28.02.09
RP_CALC_DATE_IN_INTERVAL and RP_CALC_DATE_IN_INTERVAL_SG
Both incorrectly give me 01.03.09 when asked to add 1 month to 31.01.09.
Both incorrectly give me 28.03.09 when asked to add 1 month to 28.02.09.
We're on ECC6.>
Suhas Saha wrote:
> Hello Christine,
>
> Did you check the method ADD_MONTHS_TO_DATE of the class CL_HRPAD_DATE_COMPUTATIONS ?
>
>
> * Adds No. of Months to Date
> TRY.
> CALL METHOD cl_hrpad_date_computations=>add_months_to_date
> EXPORTING
> start_date = sy-datum
> months = l_v_month
> RECEIVING
> date = l_v_date.
> CATCH cx_hrpa_violated_postcondition .
> ENDTRY.
>
>
> I dont have any idea how ADD_MONTHS function in Oracle SQL works, though ):
>
> Hope this helps.
>
> BR,
> Suhas
That also sometimes works.....but adding 1 month to 28.02.2009 gives me 28.03.2009 and adding 1 month to 29.02.2008 gives me 29.03.2008.
This is how to use ADD_MONTHS in Oracle SQL - a bit naughty since you have to use native SQL to do it but it ALWAYS seems to work. I pass a date, month number and + or - into the function module.
* For use with class based exception CX_SY_OPEN_SQL_DB.
DATA:
ex_check_os TYPE REF TO cx_sy_open_sql_db,
ex_check_rs TYPE REF TO cx_sy_native_sql_error,
ex_result(200) TYPE C,
ex_text TYPE STRING,
lv_new_date TYPE datum,
lv_old_date TYPE datum,
lv_months TYPE I.
lv_old_date = iv_date.
lv_months = iv_months.
IF iv_sign = '-'.
lv_months = lv_months * -1.
ENDIF.
TRY.
EXEC SQL.
SELECT to_char(add_months(to_date(:lv_old_date,'YYYYMMDD'),:lv_months),'YYYYMMDD')
INTO :lv_new_date
FROM sys.dual a
ENDEXEC.
CATCH cx_sy_native_sql_error INTO ex_check_rs.
ex_text = ex_check_rs->get_text( ).
ev_error_message = ex_text.
ev_return = 4.
ENDTRY.
ev_return = 0.
ev_date = lv_new_date. -
Hi,
I would like to add one day to a date. It seems like such a simple thing yet I have only found how to add a day to sysdate (or to add months to a given date).
Any help?
Thanks.
LeahHi,
If you want a specific date then it should be in date type,
so you cannot do: '01-MAR-2011'+1
but you can do: to_date('01-MAR-2011')+1
it seems to me that you just tried to add 1 to a string looking like a date
Tamir -
How to calculate Month on Month growth rates in an OBIEE query?
Dear all,
I would like to ask your help on how to calculate Month on Month growth rates [(last month - previous month)/previous month*100%] in an OBIEE query. This ratio should be always calculated for the last 2 available months.
I have the following query:
Month0 | Month1 | Month2
Product A 500 | 100 | 200
Product B 600 | 300 | 150
would like to add Month on Month column as following:
Month0 | Month1 | Month2 | Month on Month(%)
Product A 500 | 100 | 200 | +100.00%
Product B 600 | 300 | 150 | -50.00%
I tried to add a calculated item but it was not successful because I could not find out how to show only the calculated column as % with 2 decimals. Moreover, I would ideally prefer to have an automatic update but as far as I understood it can't be done in the calculated item automatically
I also tried to add a new column in the column area and to filter the results for the last month, then for the previous month and then based on it to calculate the needed ratio but unfortunately it also does not work out.
Thank you your hints in advanceHi,
The best way to solve this is using the Ago function. With this you can create a logical column for the previous month. Then you will have 2 columns available with which you can do your calculations.
If you want to do this with a calculated item (don't know if the formatting will work for you), but you can make the calculation more general by using $1 for column 1 and $2 for column 2 in your calculation. So the relative columns ($x) will change with the columns in your report.
Regards
Maybe you are looking for
-
One iTunes, multiple apple tvs, how do you set it up
Having trouble setting up multiple apple tvs one one itune account
-
Wifi is still dropping out after 6.1.2 update
Recently received a new 4s from the apple store due to moisture damage on original 4s which was very much bug free, but this phone has major wifi problems. Basically it does not scan for wifi connections. It drops out all the time, the wifi tab is gr
-
Trying to import video - deck is recognised and cued-up etc. but message appears 'Operation could not be completed as there is no video'. Went to help pages, deleted QT receipts as instructed and downloaded, once again, latest QT version. Same proble
-
Does oracle import datapump fix block corruption?
Dear all, I am having a data block corruption on production. I want to export this DB and import it to a test environment using datapump, in order to do some tests on it. However I am concerned whether impdp will resolve this scenario... and therefor
-
How to work on documentum using Java
What are the packages used? and related topics. Please help me.