Getting last days of several months - Bex Analyzer
Hello, BW experts~
I need to calculate with last days of several months.
For example,
- The sales in July: $100
-> sales per day in July = $100 / <b>31</b>
- The sales in last month(June): $100
-> sales per day in last month(June) = $100 / <b>30</b>
- The sales in 2 month ago(May): $100
-> sales per day in 2 month ago = $100 / <b>31</b>
I used to calculate a last day on a month with a customer exit variable. It works well when executing the BEx query with one month. But, when executing the query with 3 months, it doesn't work well.
For example, when executing the query in July, all last days, which are calculated via customer exit variable, become 31. Only one month.
- Last day -
July: <b>31</b>
Last month(June): <b>31</b>
2 month ago(May): <b>31</b>
They have to be each 31(July), 30(June), 31(May).
I want to get fit last days of several months at a time and one BEx query.
Is it possible? (I wish it's possible.)
Can I do something in CMOD?
Thank you~
Sihyoung Jurn
Hi,
You can get it by creating 3 formula variables with 'customer ext' as processing.
Let us assume user enters the First month by a 'user entry' variable.
In the code of user exit for 1st formula variable you will calculate the last day of the user entered month.
In the code of user exit for 2nd formula variable you will calculate the last day of the (prevoius month to user entered month).
Similarly for 3rd Formula Variable also.
there will be 3 Restricted key figures.
one for sales of user entered month.
2nd one for sales of prevoius month to user entered month.
3nd one for sales of two month to user entered month.
you will have 3 calculated kfs.
in first one you do 1st RKF/Formula variable1.
in second one you do 2nd RKF/Formula variable2.
in third one you do 3rd RKF/Formula variable3.
Hope, you understood my explanation.
With rgds,
Anil Kuamr Sharma .P
Similar Messages
-
hi ,
is there an existing date funtion to get last day of the month ?
pls advise
else
i'll try to add_month + 1 to current month and format to the first day and minus 1 day from that new month
tks & rdgslast_day function
<br>
jeneesh -
How to get last day of a month
using pl/sql
What i need is that all members whose birthdate is in the curren month will be included as having had their birthdate regardless of the date of the month. The code i have is:
Select me607.subscriber_id
me607.mbr_dob,
** trunc(months_between (*end of current month*,me607.mbr_dob) / 12) as age
from odw.mbr607_member_expanded me607
The asterixed line is what I need to change. If I put the end of the current month (where I put 'end of current month') then all those whose birthday month is in Feb will show as having had their birthdate. So if run today, folks whose birthdate is 26-feb-2005 will show an age of 5.
When grabbing the last day of the month using visual basic I just use the first day of the subsequent month minus 1. Any assistance is appreciated..Hi,
This does what you requested:
Select me607.subscriber_id, -- Don't you need a comma here?
me607.mbr_dob,
ROUND ( MONTHS_BETWEEN ( SYSDATE
, me607.mbr_dob
/ 12
from odw.mbr607_member_expanded me607
WHERE TO_CHAR (me607.mbr_dob, 'MONTH') =
TO_CHAR (SYSDATE, 'MONTH')
;If this is run sometime in February, 2010, and mbr_dob is sometime in Febrary, 2005, then the result of MONTHS_BETWEEN will be between 59 and 61. When we divide by 12 convert that to years, that difference of up to one month becomes so small that it will be lost in the rounding.
If this isn't exactly what you need, tthen post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.
Edited by: Frank Kulash on Feb 17, 2010 1:32 PM
Added explanation. -
How to get last day of prev month?
SELECT to_char(SYSDATE, 'MM') -1, last_day(sysdate)
FROM DUAL;
If current month is April, How to get the last day of March? Thanks.SQL> select sysdate, trunc(sysdate, 'mm') - 1 from dual ;
SYSDATE TRUNC(SYSDA
06-APR-2004 31-MAR-2004
1 row selected.
SQL> -
How to get the last day of a month?
HI,
I want to know how to get the last day of a month.
In my JClient form, I tried to get it by using oracle.sql.Date method, that is:
lastday=oracle.sql.Date anydate.lastDayOfMonth();
But it does not work. The result is lastday=anydate.
Why?
StephenYou can use the Calender class...
Calendar c = Calendar.getInstance();
and then something like...
c.add(c.MONTH, 1);
int dayOfMonth = c.get(Calender.MONTH);
c.add(c.DAY_OF_MONTH, - (dayOfMonth-1) );
other usefull functions are:
System.out.println(" YEAR : " + c.get(Calendar.YEAR));
System.out.println(" MONTH : " + c.get(Calendar.MONTH));
System.out.println(" DAY_OF_MONTH : " + c.get(Calendar.DAY_OF_MONTH));
System.out.println(" DAY_OF_WEEK : " + c.get(Calendar.DAY_OF_WEEK));
System.out.println(" DAY_OF_YEAR : " + c.get(Calendar.DAY_OF_YEAR));
System.out.println(" WEEK_OF_YEAR : " + c.get(Calendar.WEEK_OF_YEAR));
System.out.println(" WEEK_OF_MONTH : " + c.get(Calendar.WEEK_OF_MONTH));
System.out.println(" DAY_OF_WEEK_IN_MONTH : " + c.get(Calendar.DAY_OF_WEEK_IN_MONTH));
System.out.println(" HOUR : " + c.get(Calendar.HOUR));
System.out.println(" AM_PM : " + c.get(Calendar.AM_PM));
System.out.println(" HOUR_OF_DAY (24-hour): " + c.get(Calendar.HOUR_OF_DAY));
System.out.println(" MINUTE : " + c.get(Calendar.MINUTE));
System.out.println(" SECOND : " + c.get(Calendar.SECOND));
System.out.println();*/ -
Dynamic variable to get last day of month
Hi all,
I have created one report where in YTD is calculated based on stsyem date. NOw in this report the cal month is in row thus displaying data month wise. But i need one key figure which giving the last day vaue of every month that are displayed in YTD i.e this is based on cal day. Thus the report layout is as follows:
if report is run in mar 2007 then it should display:
For calmonth key figure due amount
For Jan 07 this should show due value on last day of jan 07 (i.e 31st jan 07)
for Feb 07 this should show due value on last day of feb 07 (i.e 28th feb 07)
for Mar 07 this should show due value on last day of mar 07 (i.e 31st mar 07)
customer exit variable can give me only one value at a time. How can I make it dynamic to take last day value of every month as per cal month. Could anybody explain me if worked on any such issue.
If there is some how to paper kindly mail me at my email Id : [email protected]
thanks in advance
Regards,
WrushaliHi,
U can use FM : SLS_MISC_GET_LAST_DAY_OF_MONTH to get the last day of the month by passing the date/current date.
Thanks,
Debasish -
How to get Last Day of a Previous Month
Hi all,
I need to get Last Day of the Previous Month. I am able to get Current Month Last Day using Calendar.getActualMaximum(Calendar.DATE)
But I need previous Month's Last Day.
Thanks
Vamshi.Thanks all....
I have been trying the same and could get it.....
here is the code for that....
SimpleDateFormat simpleDate = new SimpleDateFormat("MM/dd/yyyy");
Calendar calendar = Calendar.getInstance();
month = calendar.get(Calendar.MONTH);
//year = calendar.get(Calendar.YEAR);
calendar.set(Calendar.MONTH, month-1);
calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE));
//lastDayOfMonth = calendar.getActualMaximum(Calendar.DATE);
System.out.Println("Previous Month End Date is :: " + simpleDate.format(calendar.getTime()));
this works....
thanks for ur replys.... -
Object date - how to get the last day of the month?
hi all,
I have a date object in which I would like to get the last day of the month. any idea?
eg AUG=31
Feb = 28 (depends if a leap year)
thanksUse java.util.Calendar
Add 1 month to the day.
Set the day of month to be 1.
Subtract 1 day.
Now you are on the last day of the month you wanted. -
Defining last day of previous month in ABAP
All,
I am a BW guy and hardly know ABAP. I have a requirement where I have to calculate last day of previous month and use it in the routines of the transformations.
I have decided to define the Last day of previous month in Start routine and then use the global variable in Transformations to calculate further.
The logic that i have used is outlined below.
Define G_DATE in global declaration for further use in Transformations.
In the Routine section,
Assign G_DATE to SY-DATUM
G_DATE + 6(2) = '01' (Replace last to field of date with '01' to establish first day of the current month)
G_DATE = G_DATAE - 1 (To get to last day of previous month)
My dilemma is to implement this in ABAP in Start routine of transformations. Please include the exact ABAP code that would be needed in Declarations and Routine section.
Thanks in advance.Hi..,
Go with the function module: LAST_DAY_OF_MONTHS
So, Just determine the last month from the sy-datum and then use above function module and pick the last date of the month.
Thanks,
Naveen Inuganti. -
BIP eBusiness Suite Dates - How to include the last day of the month?
How can I get my report to include the last day of the month 'without' forcing my users to enter the non-intuitive first of the next month as a parm?
I have a report that will generally be run for a month but can be run for any pair of dates representing the first and last date to be included in the report.
When we pass the dates from Oracle Apps to the report it is truncating the date to midnight. This results in the last date entered 'NOT' being included in the report as the second date is marked as "midnight". When I attempt to simply add "=1" to the end date it fails due to formatting issues in apps (only). I have gotten this to work on our Enterprise edition server that we use for testing (only) but it fails in our apps environment.
In APPs we input the date in the format "01-AUG-2007", and this is how it shows in the parm line before the report is submitted as well as in the "View Details" after the report is executed: http://home.swbell.net/grog1//work/req_details_5607586.jpg
However it is odd in that we in the "View Log" entry it shows the date formatted as "2007/08/01 00:00:00": http://home.swbell.net/grog1/work/view_log_5607586.jpg
Even odder is that under diagnostics, "View XML" the date is formatted third way as: "2007/08/01 00:00:00.0" (note it now includes tenths of a second): http://home.swbell.net/grog1/work/view_xml_5607586.jpg
This of course makes it difficult to perform conversions and calculations on the date in the SQL.
Is APPs doing some sort of 'timestamp' conversion?
How can I get my report to include the last day of the month 'without' forcing my users to enter the non-intuitive first of the next month as a parm?
Any feedback is appreciated,
ScottNo. The problem/error occurs long before the data is formatted into xml for presentation to the format template.
The error occurs in the SQL in the 'data' template when I attempt to add a day to the date. It either does not like the implicit conversion with the "+1" and then the use of the "between" with another date or if I attempt to manually convert it has problems with the format mask.
Scott -
ICal 3.0: Last day of the month repeating event
I am migrating back to iCal after a few years using Entourage. I am trying to set up calendar events and reminders for the last day of every month, but I can't figure out how to do it. In Entourage this was easy. Any advice? Thank you.
I would like this to be an easy feature included in iCal as I get paid on the 16 and second to last day of the month. I want iCal to show the event in the calendar, not for me to set the event and have an alarm for 24 hours before. I tried the trick found at http://www.macworld.com/article/47872/2005/11/trickical.html but that does not work with iCal 3.0.
Any help would be appreciated or maybe Apple adding this in the repeating section of the ical event seeing it is apart of the icalendar specification.
tim -
Last day of previous month for data load
Hi,
I have to load data from the previous month into the psa and then into an infocube. I was wondering as to how to get the last of the previous month to write a code in ABAP. I will be writing the code at the infopackage level in the data selection. I could load data from the 1st of the previous month to the 1st of the current month. This will be an additional load of 30,000 records for the 1st of every month, since I will be loading 30,000 records everyday, I was wondering if I could limit the load from the 1st of every previous month to the last day of that month. This will be a repetitive loading.
DATA: CURR_MM(2) TYPE N,
CURR_YYYY(4) TYPE N,
CURR_DD(2) TYPE N,
PREV_MM(2) TYPE N,
PREV_YYYY(4) TYPE N,
PREV_DD(2) TYPE N,
YYYY_MM(6),
YYYY_MM1(6),
DATE LIKE SY-DATUM.
DATE = SY-DATUM.
CURR_YYYY = DATE+0(4).
CURR_MM = DATE+4(2).
CURR_DD = DATE+6(2).
PREV_DD = 1.
IF CURR_MM = '01'.
PREV_MM = '12'.
PREV_YYYY = CURR_YYYY - 1.
ELSE.
PREV_MM = CURR_MM - 1.
PREV_YYYY = CURR_YYYY.
ENDIF.
concatenate PREV_YYYY PREV_MM PREV_DD into YYYY_MM.
concatenate CURR_YYYY PREV_MM PREV_DD into YYYY_MM1.
read table l_t_range with key
fieldname = 'BLDAT'.
l_idx = sy-tabix.
l_t_range-low = YYYY_MM.
l_t_range-high = YYYY_MM1.
l_t_range-sign = 'I'.
l_t_range-option = 'BT'.
modify l_t_range index l_idx.
p_subrc = 0.
Mind you this code will load data from 1st of the previous month to the 1st of current month. I just don't want to load that extra "1st day" of current month data as I have 30,000 records everyday.
Say for example, I want to load data from 1st Mar to 31st Mar or 1st Feb to 28thFeb. How should I modify the above code.
Is there a formula to get the last date of the previous month. That's all I need. This would solve the problem.try this routine. it will return a range from 1st day to end of the month.
DATA: l_s_range TYPE rsr_s_rangesid,
E_T_RANGE TYPE RSR_T_RANGESID.
DATA: year(4) TYPE n,
month(2) TYPE n,
day(2) TYPE n,
ld_keydate TYPE sydatum,
ld_lastday TYPE sydatum.
REFRESH e_t_range.
CLEAR l_s_range.
year = sy-datum(4).
month = sy-datum+4(2).
*Months with 31 days in year
IF month = '01' OR
month = '03' OR
month = '05' OR
month = '07' OR
month = '08' OR
month = '10' OR
month ='12'.
day = '31'.
ENDIF.
*check for leap year: provoking sy-sybrc <> 0
IF month = '02'.
day = '29'.
MOVE: '02' TO ld_keydate+4(2),
year TO ld_keydate(4),
day TO ld_keydate+6(2).
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
date = ld_keydate
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
day = '28'.
ENDIF.
ENDIF.
*months with 31 days in year
IF month = '04' OR
month = '06' OR
month = '09' OR
month = '11'.
day = '30'.
ENDIF.
MOVE: year TO ld_lastday(4),
month TO ld_lastday+4(2),
day TO ld_lastday+6(2).
l_s_range-low = sy-datum.
l_s_range-high = ld_lastday.
l_s_range-sign = 'I'.
l_s_range-opt = 'BT'.
APPEND l_s_range TO e_t_range. -
SQL select Statement -first day and last day of the month - 1 year from now
Hi,
I need to write a SQL to get the dates in between first day and last day of the month one year from now.
SELECT last_day(add_months(sysdate,12)) as lastday from dual
What could be the Query to get the first day of the month one year from now..
ie ..Sysdate - 3-DEC-2009
Result - 1-DEC-2010
thank youHi,
You can use TRUNC with 2 arguments to get the first DATE in a month, year, quarter, week, hour, minute, ISO year, ...
SELECT TRUNC ( ADD_MONTHS ( SYSDATE
, 12
, 'MONTH'
) AS first_of_month
FROM dual
;The DATE returned will be in the same month, year, quearter, ... as the first argument.
\We convered the last day of the month in [your previous question|http://forums.oracle.com/forums/message.jspa?messageID=3942939#3942939].
At that time, I warded about using LAST_DAY as a cutoff point; TRUNC is a much better way.
For example, to find all appointment_dates in the current month next year:
SELECT *
FROM appointments
WHERE appointment_date >= TRUNC (ADD_MONTHS (SYSDATE, 12), 'MONTH')
AND appointment_date < TRUNC (ADD_MONTHS (SYSDATE, 13), 'MONTH')Note that
the first part of the WHERE clause calls for dates on or equal to the beginning of the 12th month in the future, but
the second part of the WHERE clause calls for dates before, not equal to , the beginning of the 13th month in the future. -
Display a metric differently only on last day of the month.
Have a Daily transaction fact where unit cost of product is stored at a day/part num /business unit level.
When we drag and drop date column and unit cost in the report like below we will have
Date cost
Sep29 $10
sep30 $12
Oct1 $12
Oct2 $14
..........ans so on
The source sustem program runs on last day of the month around 8pm for setting up cost to reflect on 1st of every month
But the nighly OBI load ( Runs at 2am every day) when incrementally updating Sep30 data picks up $12 from the erp and populates in OBI.
But actually speaking, on Sep30 the cost was $10.
There is no way of running the ERP program to run afer OBI load. Hence we need an expression in the RPD (not answers) saying
when last day of the month (any month) the standard cost must be a previous day value.All other days the same value should be returned.
Is this possible without impacting report performance ?
So, when we drag and drop date and cost value the above report should change as
Date Cost
sep29 $10
sep30 $10
Oct1 $12
Oct2 $14
Oct30 $12.5
Oct31 $12.5
Nov1 $13.5You can achieve the above requirement for current month alone with below steps:
The solution requires to have a union report
First part of the report will have Date and Cost fields with a report level date filter, Date NOT IN (TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))))
Second part of the report will have Date and Cost fields with a report level date filter Date IN (TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))))In the second part of the report,
Change the column formula for Date to display only Current_Date
Change the column formula for Cost field with FILTER(Cost USING Date = Current_Date-1)
Pls mark if correct/helpful. -
How do I set a reminder for the last day of every month
Have I missed something? But how do you set a reminder for the last day of every month to recurr indefinatley in iOS6? Sorry if this is really simple but I just can't seem to work it out. Any help gratefully received.
Hey Mattye88 not sure if you have seen but actully you can do this, but for some reason you have to use Siri. If you bring up Siri and say "set a reminder ever 4 weeks from next wednesday to check the gas meter" it will set one and it will work just fine, I have reminders to water a Bonsai every three days and it works fine it just shows as custom repeat on the user interface. Alas it seems you can not use Siri to set one for the end of the month though which is why I am in this threed. Still hope it helps you to know how to sort this problem atleast.
Maybe you are looking for
-
Will the ipad 3rd gen be able to get iOS 7?
I keep finding mixed anwsers all I want to know is if I will be able to get iOS 7 on my ipad 3rd gen
-
Controlling the share permission when writing a text file
I have several application that writes a delimited text file to a file share. Another application, not a LabVIEW application then reads the delimited text file. When my application is creating and/or writing to the delimited text file, is there a w
-
HT1420 The menu does not come up when i press alt
it says that when i press alt then the menu should appear, but it doesn't. how do i get it to?
-
The Consequences of putting a tablespace into Hot Backup mode--Link to Doc
http://www.dizwell.com/prod/node/10 This article will help beginners who want to know what exactly happens when the Tablespace is put in Backup mode
-
I am buying a new Mac and because of this I wonder, having the CS 4 Master Collection, if it's compatible with Mac OS 10.8 Mountain Lion.. or will there be any problem of any kind with the software? If so, how can it be helped, the easiest way? I mea