To show previous 12 months from current month.
I have one column Time.Month (Char column) with values in the format 2011 / 09. In my report i want to show previous 12 months from the current month. I dont have any date prompts in my report. Pls help.
Use the below query in init block to create a repository variable as PREVIOUS_12_MONTH
SELECT PRV.PER_NAME_MONTH FROM VALUEOF(OLAPTBO).W_DAY_D PRV , VALUEOF(OLAPTBO).W_DAY_D CUR WHERE convert(char(12),PRV.DAY_DT)=convert(char(12),CUR.YEAR_AGO_DT) AND convert(char(12),CUR.DAY_DT)=convert(char(12),getdate()-valueof(time_offset))
Variable PREVIOUS_MONTH: Use the below query in init block
SELECT PRV.PER_NAME_MONTH FROM VALUEOF(OLAPTBO).W_DAY_D PRV , VALUEOF(OLAPTBO).W_DAY_D CUR WHERE convert(char(12),PRV.DAY_DT)=convert(char(12),CUR.MONTH_AGO_DT) AND convert(char(12),CUR.DAY_DT)=convert(char(12),getdate()-valueof(time_offset))
Create a filter in Answers as below and use where ever you wish:
Month is between PREVIOUS_12_MONTH and PREVIOUS_MONTH
Use it in the report with current month Or previous month as per your requirements.
Pls mark if helps
Similar Messages
-
Customer Exit for 13 month from current month
Hi Gurus,
I need a customer exit for 13 months from current month. Based on the requirement I have written following code
When 'VPI_13CALYRMON'.
IF i_step = 1.
l_s_range-sign = 'I'.
l_s_range-opt = 'BT'.
l_s_range-low = sy-datum+0(6).
l_s_range-high = sy-datum+0(6) + 13.
append l_s_range to e_t_range.
endif.
Please could you guide me the code.
Thanks
Ganesh Reddy.Hi,
I think you can do it in below way.
When 'VPI_13CALYRMON'.
IF i_step = 1.
temp1 = sy-datum+0(4).
temp1 = temp1 +1. (because adding 13 months would take year to next year)
temp2 = sy-datum+4(2).
temp2 = temp2 + 1. (after adding 13 months, the month would be one more than of previous year)
concatenate temp1 temp2 into temp3.
l_s_range-sign = 'I'.
l_s_range-opt = 'BT'.
l_s_range-low = sy-datum+0(6).
l_s_range-high = temp3.
append l_s_range to e_t_range.
endif.
Hope this helps. -
Customer Exit for 15 month from current month
Hi Gurus,
I have a requirement to write customer exit for 15 months from current month based on todays day.
if current day is less than 10 then we have to get 15 months from current month other wise from next month to 15 months.
this exit I am writing on calendar year/month.
Please assist for logic.
Thanks
Ganesh Reddy.I hope this code will do the trick.
DATA: L_S_RANGE TYPE RSR_S_RANGESID,
LOC_VAR_RANGE LIKE RRRANGEEXIT,
zcalmonth(6) type c.
zcurrentmonth(6) type c.
zyear(4) type n,
znextyear(4) type n,
zyear1(4) type c,
znextyear1(4) type c,
zmonth(2) type n,
zmonth1(2) type n,
zmonth2(2) type c,
zmonth3(2) type n,
zmonth4(2) type c,
IF i_step = 2.
CASE i_vnam.
WHEN '<VARNAME>'.
zyear = sy-datum+0(4).
znextyear = zyear + 1.
zyear1 = zyear.
znextyear1 = zlastyear.
zmonth = sy-datum+4(2).
if sy-datum+6(2) LE 10.
zmonth1 = zmonth + 2.
if zmonth1 GT 12.
zmonth1 = zmonth1 - 12.
zmonth2 = zmonth1.
zcurrentmonth = sy-datum+0(6).
endif
concatenate znextyear1 zmonth2 into zcalmonth.
else.
zmonth1 = zmonth + 3.
ZMONTH3 = ZMONTH + 1.
if zmonth1 GT 12.
zmonth1 = zmonth1 - 12.
zmonth2 = zmonth1.
endif
if zmonth3 GT 12.
zmonth3 = zmonth3 - 12.
zmonth4 = zmonth3.
endif
concatenate znextyear1 zmonth2 into zcalmonth.
concatenate znextyear1 zmonth4 into zcurrentmonth.
endif.
l_s_range-low = zcurrentmonth.
l_s_range-high = zcalmonth.
l_s_range-sign = 'I'.
l_s_range-opt = 'BT'.
APPEND l_s_range TO e_t_range.
ENDIF.
ENDIF.
rgds, Ghuru -
Subtraction 3 months from current month and store in a report output
Hi Gurus,
Currently my requirement is my clinet is having 2 sales organization one in usa and one in china.
They are using one report for sales comparison. The issue is when client enter the sales organization number like 1002 for china the output should like
Period 06 => SEP (usa spetember amount should come in 1002 organization june filed in the report
Period 07 => OCT(like wise oct amount for in august. This process should continue for every month.
provide sample program or logic.Subtracting days to determine month is not a good idea, as each month can have different number of days.
If you want to be precise act on month value in date like this:
data: period type i, "data for stroing period
c_period(2) type n. "period in format 01,02, 03
period = sy-datum+4(2) - 3. "take 3 months before actual date
"if the result is less or equal 0 (then we have to back to to previous year)
"it will be applicable only for JAN, FEB and MARCH months
if period le 0.
ADD 12 to period.
endif.
c_period = period. "now in c_period you have 3 months before today -
Retrieving remaning months of current year from current month
Hi,
I would like te retrieve the remaining months of current year from current date.
I can I achieve this?
For example today is 23 july 2012.
Then I would like to have:
August
September
October
November
December
Thanks,
DianaSomething like this:
with generate_months as (select to_char(add_months(trunc(sysdate, 'mm'), level -1), 'fmMonth', 'nls_date_language=english') months, level lvl
from dual
connect by level <= months_between(add_months(trunc(sysdate, 'yyyy'), 12), trunc(sysdate, 'mm')))
select months
from generate_months
where lvl != 1;
MONTHS
August
September
October
November
December Edited by: Boneist on 23-Jul-2012 16:42
Fixed the query so that it wouldn't show any months when sysdate is in December.
Also, this is a duplicate of retrieving remaning months of current year from current month (shame I didn't spot that before adding my solution! Oh well...) -
How to get name of the month from current date.
Hi,
How to get the name of the month from current date.
Thanks,
SenthilSethil,
Use your date(let us say Date1) instead of sy-datum.
CALL FUNCTION 'MONTH_NAMES_GET'
EXPORTING
LANGUAGE = SY-LANGU
IMPORTING
RETURN_CODE =
TABLES
MONTH_NAMES = itab_month
EXCEPTIONS
MONTH_NAMES_NOT_FOUND = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
READ TABLE itab_month
WITH KEY MNR = date1+4(2).
itab_month-LTX will contain the value you are looking for
Good luck
Raghava -
Display three prior months starting from current month
Hello All,
I came across the requiremnt:
The report looks like:
2014-Jan
2014-Feb
2014-Mar
2014-Apr
2014-May
2014-June
2014-July
2014-Aug
2014-Sep
2014-oct
2014-Nov
2014-Dec
A
122
233
233
233
233
233
233
233
233
233
233
233
B
22
33
33
33
33
33
33
33
33
33
33
33
C
33
33
33
33
33
33
33
33
33
33
33
33
D
333
3333
3333
3333
3333
3333
3333
3333
3333
3333
3333
3333
The requirement is to display the prior 3 months ,current month, next 3 months.
Assume that current month is SEPTEMBER, the report should look like:
2014-June
2014-July
2014-Aug
2014-Sep
2014-oct
2014-Nov
2014-Dec
A
233
233
233
233
233
233
233
B
33
33
33
33
33
33
33
C
33
33
33
33
33
33
33
D
3333
3333
3333
3333
3333
3333
3333
Share your thoughts.
ThanksHello All,
I got this resolved using the below formula to get either prior 3 months or the next 3 months from current date:
3rd month from current date:
=LastDayOfMonth(RelativeDate(LastDayOfMonth(RelativeDate(LastDayOfMonth(RelativeDate(LastDayOfMonth(CurrentDate()); 1));1));1))
Prior 3rd month from current date:
=ToDate(FormatDate(RelativeDate(ToDate(FormatDate(RelativeDate(ToDate(FormatDate(RelativeDate(ToDate(FormatDate(CurrentDate();"MM/yyyy");"MM/yyyy");-1);"MM/yyyy");"MM/yyyy");-1);"MM/yyyy");"MM/yyyy");-1);"MM/yyyy");"MM/yyyy")
and used these objects to restrict my date field(date object between "Prior 3rd month from current date:" and
"Prior 3rd month from current date:"
Thanks,
Vijay -
Subtracting months from current date
how to subtract months from current date in mysql
You are in an Oracle forum, so the Oracle answer is: use add_months(sysdate,-2) to subtract two months from the current date.
Regards,
Rob. -
Get last august month from current date
Hi,
I need to get last august month from current date.
e.g if current date is 1-OCT-2013 need to get last August date i.e.1-AUG-2013
e.g. if current date is 1-MAY-2013 need to get last August date i.e.1-AUG-2012Something like this?
SQL> WITH table_x AS(
2 SELECT SYSDATE dt from dual UNION ALL
3 SELECT TO_DATE('20-05-2013','dd-mm-yyyy') from dual
4 )
5 --
6 ---
7 --
8 SELECT dt,
9 CASE
10 WHEN (dt >= Add_Months(TRUNC(dt,'YEAR'),7)) THEN
11 Add_Months(TRUNC(dt,'YEAR'),7)
12 WHEN (dt < Add_Months(TRUNC(dt,'YEAR'),7)) THEN
13 Add_Months(TRUNC(dt,'YEAR'),7) - 365
14 END cs
15 FROM table_x;
DT CS
24-OCT-13 01-AUG-13
20-MAY-13 01-AUG-12 -
Query for fiscal month till current month of year
Hi,
can you please help me to show only fiscal months till current month of year?
e.g. Current month is Apr of 2012.
I have to show the fiscal months till the Apr 2012 of year 2012.
if the date is 24th of Apr then it would show May month also.
Regards,
Nileshwith t as (
select to_date('04232012','MMDDYYYY') d from dual union all
select to_date('04252012','MMDDYYYY') from dual)
select
d,
case
when to_char(d,'DD') >= 24 then
to_char(trunc(add_months(d,1),'MONTH'),'MM-YYYY')
else
to_char(d,'MM-YYYY')
end fin_month
from t
D FIN_MONTH
23.04.2012 04-2012
25.04.2012 05-2012 -
i have a scenario where i need the data of last date of every month and if the month is current month need current date data...
is it possible using MDX...Hi Shashi,
According to your description, you want to return the last day for each month except current month, right?
In MDX, we can use ClosingPeriod function to return the member that is the last sibling among the descendants of a specified member at a specified level, here is a sample query for you reference.
with member [measures].[a]
as
ClosingPeriod ([Date].[Calendar].[Date],[Date].[Calendar].currentmember).name
select {[measures].[a]} on 0,
[Date].[Calendar].[Month].members on 1
from
[Adventure Works]
And then use the IIF function to evaluate if the month is current month. Please refer to the links below.
http://msdn.microsoft.com/en-us/library/ms145584.aspxhttp://msdn.microsoft.com/en-IN/library/ms145994.aspx
Regards,
Charlie Liao
TechNet Community Support -
How to get last week of the month from a month
Hello,
I want to get last week of the month from a month. For example: If Input = April then Output = Week17. Is there any function module? Or what should be the logic inorder to meet such requirement?
Thanks in advance for your answers.
Nitin.Hi,
Just cpoy and past this program, and see the result and apply for you requirements.
Data: ZSCDATUM TYPE SCDATUM,
ZKWEEK TYPE KWEEK,
ZDAY TYPE SY-DATUM,
ZLDAY TYPE SY-DATUM,
ZWK(3) TYPE N,
ZM(2) TYPE N.
ZDAY = SY-DATUM.
ZM = ZDAY+4(2).
CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
EXPORTING
day_in = ZDAY
IMPORTING
LAST_DAY_OF_MONTH = ZLDAY
* EXCEPTIONS
* DAY_IN_NOT_VALID = 1
* OTHERS = 2
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ZSCDATUM = ZLDAY.
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
date = ZSCDATUM
IMPORTING
WEEK = ZKWEEK
* EXCEPTIONS
* DATE_INVALID = 1
* OTHERS = 2
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ZWK = ZKWEEK+4(2).
WRITE: ZKWEEK.
WRITE: ZWK.
Thanks
Reddy -
How to get previous 2 months from current date in a dropdown?
Hello Experts ,
In the application which I am developing, there is a requirement wherein , I want to Populate current month and previous two month in a drop down depending upon today's date. please help.
Thanks & Regards,
Pratbha ShuklaThe internal format for dates is yyyymmdd. Therefore you can just grab the month value from the date:
data lv_month type FCMNR.
lv_month = lv_date+4(2).
Just subtract from the month to get the two previous.
data lv_previous1 type FCMNR.
data lv_previous2 type FCMNR.
if lv_month = 1.
lv_previous1 = '12'.
else.
lv_previous1 - lv_month - 1.
endif.
if lv_previous1 = 1.
lv_previous2 = '12'.
else.
lv_previous2 - lv_previous1 - 1.
endif.
Then do your lookup for the month name by reading the table returned from function module MONTH_NAMES_GET. -
Want to show data from current month & prev month in single record on forms?
Hello experts,
i have this requirement:
Table structure:
MOnth Division totalAmount
01-apr-2013 1 10000
01-May-2013 1 20000
01-apr-2013 2 30000
01-May-2013 2 50000
i want to display in forms like
Form:
Month : 01-May-2013
Month Division total prev_Month division total dIFFERENCE
01-May-2013 1 10000 01-Apr-2013 1 20000 10000
01-May-2013 2 30000 01-Apr-2013 2 50000 20000
I am using two procedure for fetching records for current month and previous month.
but it will cause problem, if for some division previous month data not present.
please suggest me some query with which i can fetch current and pre month data in single record.
Please help me out.
Thanks
yashI'M NOT SURE BUT TRY IT ............
select x.mn mnth, x.division, x.totalAmount total, y.mn prev_month, y.division, y.totalAmount total, (y.totalAmount - nvl(y.totalAmount,0)) difference
from
(select month mn, division, totalAmount
from table_name
where month = (select max(month)
from table_name
) x,
(select month mn, division, totalAmount
from table_name
where month = (select add_months(max(month),-1)
from table_name
) y
where x.division = y.division(+)
MOSTAFIZ MITUL
DHAKA BANGLADESH -
Hi,
I have a Time Reporting site where users log in their time twice a month.This site uses only Out Of Box functionality. There is no scope for coding in my site.
In the list i have created a view which shows the Time Report of the user logged in for the current month only.
There is a new requirement : Current month's Time Report should be visible to the users in the next month for 5 starting days of the month only so that users can edit this month's Time Report in the next month's 1st 5days incase they forget to edit it in
the current month.
e.g: If i am absent on the last day of the month , my time report for this month(March) should be visible for 5 days in April so that i can stiil edit March's time report. However after 5days the Time Report for March should not be visible. After 5days only
April's time report will be visible when submitted(April's time report).
Please can anybody help me out with this.
Regards ,
GuruHi Guru, you have a couple of options: 1) set a retention schedule through the list's settings> Information Management Policy Settings. Where the start date < start date + 35.
2) create a view and filter by the date like above.
These aren't perfect scenarios, but will get you close to what you want.
cameron rautmann
Maybe you are looking for
-
Which views/tables to use for retrieving item information
Hi All, I need to write a PL/SQL procedure for retrieving detailed information for a specified item (given inventory item ID and organization ID). I'm not quite sure which views/tables to us for this. I found out that view MTL_SYSTEM_ITEMS_FVL is the
-
hi friends in prepare automatic posting for foreign currency tc.oba1 KDB, KDF, KDW, KDZ, RDF what is difference between thease exchange keys what purpose use thease keys individually explain regards shiva
-
Adding Sales Offices to Mini Templates CRM Enhancement
Hi, I have a problem in CRM with mini-templates. In the standard, you can set predefined values for Sales or shipping or other things. The problem is that in the organizational tab, we could enter the sales office, the division and the district and w
-
Does Lion allow you to edit the Address Book chat list yet so you can add Skype or Gmail? Real pain not having these Thanks Carl
-
Illustrator CS6 crash on startup
I had this issue but after reinstalling Windows, it was gone... But now it has came back again... When launching alone or with a file I got the following error After closing it, the process still continue to run in background If I try to load it with