Getting Previous Period Date
Hello - I'm wondering if anyone can help.
Im currently developing a tool which filters and aggregates some data. I have the user to be able to select a period for example - 01/01/2010 to 07/10/2010.
Then, I want to compare the selected data with the same period of the previous.
I understand that I think I get do this with the .getTime function but Im at a loose end as to how to achieve this. Another example is if the user selects 2 years, e.g. 01/01/2010 - 01/01/2008 the comparison period would be 01/01/2006 - 01/01/2008
Please help!
Thanks
Craig
public function filterAll(evt:Event):void
var tmpDate:Date = selectedFrom.selectedDate
var tmpDate2:Date = selectedTo.selectedDate
tmpDate.time = tmpDate.getTime();
tmpDate2.time = tmpDate2.getTime(); // this needs to be the previous period
trace (tmpDate)
trace (tmpDate2) // trace previous period
Think I've done it! Here is the function for anyone that is interested!
public function getPreviousPeriod(From:Date,To:Date, fromOrTo:String):Date
var diffNum:Number = From.getTime() - To.getTime();
var tmpDate:Date = new Date
var tmpDate2:Date = new Date
tmpDate.time = From.getTime();
tmpDate2.time = To.getTime();
tmpDate.time = tmpDate.getTime() + diffNum
tmpDate2.time = tmpDate2.getTime() + diffNum
if (fromOrTo == "From")
trace ("FROM")
return tmpDate;
else
trace ("TO")
return tmpDate2;
Similar Messages
-
How to get previous day data if i dont have current day data.
Hello Gurus,
I have a stock levels data in ODS. when there is no movements, we are not getting any stocks into ODS. So we have to get previous day data as it is for current day data into another ODS.
Could you please help me in this regard.
Thanks in advance,
RamaRama -
0CALDAY can't help us in this scenario .
Step 1 :
To do this - You have to add one ZDATE (InfoObject ) to 1st ODS. ZDATE is updated by itself from current date of system when ever you are loading data to 1st ODS.
Step 2:
You have to do full update to 2nd ods.At the selection screen of InfoPackage (from 1st ODS to 2nd ODS ) you have to write following code for ZDATE.
pseudo Code:
1) Select fields "Rec_INSERT","Time stamp","Request Status" and "Request ID" where ICUBE = ODS1 from table "RSMONICDP"
2) Populate above selected fields data in INTERNAL TABLE
3) Sort INTERNAL TABLE by Time stamp .
4)
If (Record Count = ' 0 ' for current date in internal table )
update records from ODS1 to ODS2 where ZDATE = "yesterday date"
else
update records from ODS1 to ODS2 where ZDATE= "today date"
endif.
Make sure this is full update not delta update from ODS1 to ODS2
I am sorry, I m not good in Coding but I am sure if u use this logic,You can meet your requirement.
I hope you can understand my logic. Let me know if you have any questions,
Anesh B . -
Get previous bill date using SQL
Hi,
I am table which holds records for bill generation. I have column name gene_bill_date which is date field and it holds a value the date on which the particular bill was generated.
Now I am trying to get previous bill date, not the current bill date. I can to Max(gene_bill_date) to get current bill date, but how do I get previous bill date?
thanksHi,
Sorry, it's unclear what you're asking.
You didn't post any sample data, so I'll use the scott.emp table to illustrate. Let's say we're interested in deptno=30 only, just to reduce the output from 14 rows to 6.
If, for every row, you need to know the most recent gene_bill_date before the one on that row, you can do something like this:
SELECT ename
, hiredate
, LAG (hiredate) OVER (ORDER BY hiredate) AS prev_hiredate
FROM scott.emp
WHERE deptno = 30
;Output:
ENAME HIREDATE PREV_HIREDA
ALLEN 20-Feb-1981
WARD 22-Feb-1981 20-Feb-1981
BLAKE 01-May-1981 22-Feb-1981
TURNER 08-Sep-1981 01-May-1981
MARTIN 28-Sep-1981 08-Sep-1981
JAMES 03-Dec-1981 28-Sep-1981Are you only interested in the 2 most recent dates in the whole result set?
If so, do a Top-N Query , like this:
WITH got_r_num AS
SELECT ename
, hiredate
, RANK () OVER (ORDER BY hiredate DESC) AS r_num
FROM scott.emp
WHERE deptno = 30
SELECT *
FROM got_r_num
WHERE r_num <= 2
;Output:
ENAME HIREDATE R_NUM
JAMES 03-Dec-1981 1
MARTIN 28-Sep-1981 2
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using. -
Mdx expression to get previous period month
My dimension table has a column for current period month, where every row has the same value, updated at the end of the month. I am using the following expression to get current period month. "Jan - 2009" is randomly chosen, as every
cell on that column will have the same value.
[Time].[Time].[Month].[Jan - 2009].Properties( "Current Period" )
Result of the above expression is "Feb - 2015".
Current period month will always be previous month of the current year. example: During Jan - 2015, current period month is Dec - 2014.
I need to use this expression or any function to get the previous month. For example if the current period month is Feb - 2015, then the previous period month should give me Jan - 2015.
How can I accomplish that?Hi
I have a similar situation but not with date dimesion we have sales seasons in retails domain.
please check how I am handling this
select (LinkMember ([ProductSeason].[Current Season].firstChild,
[ProductSeason].[Season Name])).prevmember
on columns,
[Measures].[Total pcs]
on rows
from [NewCube]
fsdfasdf
Here I have column currect season which get update at the start of each season with currect season
name. then I am receiving the season name member from product season dimension and fetching the previous member for that.
Hope this will help.
Regards,
Rahul
lntinfotech -
Hi
how to get upto previous month data
if select aug-11 then i get upto jul-11 data for the aug-11
how to do this
i have gldate,startdate,enddateHi
thanks for ur reply but
but my requirement is different
actually i have some date columns
my condition is gldate<startdate
my values are
gldate values are like 1/31/2011,2/28/2011,3/31/2011,4/30/2011,5/31/2011 ...
startdate values 1/1/2011,2/1/2011,3/1/2011,4/1/2011,5/1/2011 ..
periodname --jan-11,feb-11,mar-11 likethsi
if i select periodname nov-11 then
startdate is 11/1/2011 and gldate is 11/30/2011
my condition is gldate<startdate its false then all gives 0's
my requirement is if i select periodname nov-11 then startdate is 11/1/2011 then iget the amount for the all gldate values <startdate
startdate i compare all gldate values its not filtered
then this condition get upto oct-11 values
i nees for nov-11 values are upto oct-11 values sum
plz how to dothis
if ur not understand plz reply to me -
FM to get previous sunday date based on current date(SY-DATUM)
hi all,
Is there any function module to get the previous sunday date based on current date(sy-datum)?
Regards,
Kapil SharmaHi Kapil,
You can follow the logic below:
data:
l_date like sy-datum, **TODAY
l_date2 like sy-datum, **Previous Sunday
data:
l_daynr like HRVSCHED-DAYNR.
*Get today's date
l_date = sy-datum.
*Gey today's day (Monday, Tuesday, etc.)
CALL FUNCTION 'HRIQ_GET_DATE_DAYNAME'
EXPORTING
langu = 'EN'
date = l_date
IMPORTING
daynr = l_daynr.
CASE l_daynr.
*If it is Monday
WHEN 1.
-Subtract 2 days for the previous Sunday
CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
EXPORTING
id_date = l_date
id-operator = '-'
is_duration = 2
IMPORTING
ed_date = l_date2.
*If it is Tuesday
WHEN 2.
CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
EXPORTING
id_date = l_date
id-operator = '-'
is_duration = 3
IMPORTING
ed_date = l_date2.
*If it is Wednesday
WHEN 3.
CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
EXPORTING
id_date = l_date
id-operator = '-'
is_duration = 4
IMPORTING
ed_date = l_date2.
*If it is Thursday
WHEN 4.
CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
EXPORTING
id_date = l_date
id-operator = '-'
is_duration = 5
IMPORTING
ed_date = l_date2.
*If it is Friday
WHEN 5.
CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
EXPORTING
id_date = l_date
id-operator = '-'
is_duration = 6
IMPORTING
ed_date = l_date2.
*If it is Saturday
WHEN 6.
CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
EXPORTING
id_date = l_date
id-operator = '-'
is_duration = 7
IMPORTING
ed_date = l_date2.
*If it is Sunday
WHEN 7.
CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
EXPORTING
id_date = l_date
id-operator = '-'
is_duration = 8
IMPORTING
ed_date = l_date2.
ENDCASE.
Regards,
Dilek -
Getting previous weeks data based on parameters entered
I am using CRXI. I have a RT that gives me the current week data but I need to be able to report on previous week data based on the paraments so if I enter dates between sunday and saturday of one week it will report on those data plus the same days of the previous week. I looked at the lastfullweek function, but not sure how to implement it in my scenerio. any ideas?
RalphThat worked, thankyou. My next question along the same lines, is I am also having a third column that will indicate the percent change. for example
Current Previous % Change
97 108
I am trying to computer the % change between curent and previous basically it would look at previous as being the control and computer positive or negative based on what current is. I can do the math formulas, but I'm not sure what to comute to find the % change.
Ralph -
How to get previous month data from current month values
Hi Experts,
I have made one universe from BW Query in which Fiscal year period is entered in interval.
I have made a universe from that and want to develop webI reports on top of that.
In my webI reports, i have used one cross tab. In Rows section i have added Company Code and in Column section i have used Fiscal Year/Period and in Value section i have added Sales Value. I want this value of previous month.
Requirement:
Ex.
Feb'09 Mar'09 and so on...
Comp_code1 Sales of Jan'09 Sales of Feb'0f and so on....
I am getting this.
Ex.
Feb'09 Mar'09 and so on...
Comp_code1 Sales of Feb'09 Sales of Mar'09 and so on....
I hope i have clear my requirements.
Please help as soon as possible.
Thanks in Advance,
RishitHi Rishit,
Follow the below steps to get the desired result.
Step1: Convert your fiscal year period from char to a date in your database or in your designer however its feasible.
to_date('substr('009.2009',2)','mm.yyyy')
you will get the result 01 sep 2009
Step2: Convert this format to 01/09/2009 by using date functions.
Step3: Create a Detail associated to the 'date' field (typically your fiscal period).
Step4: Create a cross tab Like : Rows section should have Company Code and in Column section should have 'date'(created detail) and in Value section should be Sales Value.
you should get the following result.
01/02/2009 01/03/2009 and so on...
Comp_code1 Sales of Feb'09 Sales of Mar'09 and so on....
Step5: Use the following formula in your Column (date) formula bar.
=(<date>-1)-DayNumberOfMonth(<date>-1)+1
You will get the following result:
01/01/2009 01/02/2009 and so on...
Comp_code1 Sales of Feb'09 Sales of Mar'09 and so on....
Format the cell according to your reruirement.
Let me know if you will get any break in the above steps.
Regards,
Swati. -
Hi,
My db has following:
Year Sales Target (10 % more of Previous year's Sales)
2007 10000 -
2008 15000 11000
2009 18000 19500
2010 20000 19800
2011 10000 22000
I have a filter set to retrieve data for Current Year and (Current - 3) years, and I get following
Year Sales Target (10 % more of Previous year's Sales)
2008 15000 0
2009 18000 19500
2010 20000 19800
2011 10000 22000
I want to display the value (Target) for 'Year 2008' (as the previous year sales data is present);
Is it possible to get it?
Regareds,
JitendraMatt!
Would you please explain, how to achieve this in Pivot?
Regards,
Jitendra -
I have a situation, where i need to write expression Period to date(PTD). i want to know how to get the period date. i want you to help in writing Period date or else is there any function to get period date for a given date(the date is given
from the parameter dynamically) in MDX for SSRS report
ramHi ram,
Per my understanding that you want to get the period date based on the month selected and the given date, right?
Could you please provide details information below to help us better understanding your requirements, thus we will be more effective to provide an solution:
What is the format of the period date you want to get, is this date in the DB and you want to filter it based on the month and the given Date?
Did the month and given date are two parameters in the report? if possible, could you please provide some sample data in the DB and also the snapshot of the report structure
I assume you want to get the period date(mm/dd/yyy) between the select month(e.g:Feb) and the given date (10/1/2014) and you should get the date between(02/01/2014-10/1/2014).
If so,and you also have two parameter "Month","EndDate"(EndDate is the given date), please reference to details information below:
You can create an new parameter "BeginDate" (Date/Time) which is the begin date of the period, you can use the expression to get the value based on the value of the month and the year value from the given date,finally hide this parameter:
Specify the available value:
Label:=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value)
Value:=CDate(=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value))
Specify the default Value:
Value:=CDate(=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value))
Add filter to the dataset as below:
Preview you will get all the date in the given Period:
If you still have any problem, please feel free to ask.
Regards
Vicky Liu -
Table for previous period stock
Please provide me the table name or report from which I can get only quality stock in previous monht
I just need the quality stock in previous month
need a tablexxxxH tables certainly have correct data, just not in good readable form.
you need to use a function module to retrieve the previous period stock:
A calculation of previous period data for table MARD could have the following form.
select * from mard into table mard_tab where werks = 'ABCD'.
call function 'MARD_EXTEND'
exporting
xvper = 'X'
tables
mard_tab = mard_tab.
table MARD_TAB is filled with the previous period information. -
Hi Experts,
Currently in my program previous period data can be pulled from MBEW using MBEW_EXTEND putting XVPER = X . How can I pull the current period data from MBEW and which stock field should I need to consider for it?
call function 'MBEW_EXTEND'
exporting
xvper = 'X'
tables
mbew_tab = tab_temp.
Thanks in advance.hi,
table MBEW is for material valuation table, irrespective of the period. here there is no bifurcation of this current period and previou period.
MBEWH- is material valuation history table.
here current period running active period in which the posting is beeing done.
previous period is one month before the current period.
here in MBEWH, an option is given to fill the last current month as required for fetching the data.
Edited by: manipal on Jan 10, 2008 4:56 AM -
Costs of previous period not getting settled in current period ?
Dear All,
Scenario - Ours is an investment project. User has forgotten to settle costs in previous financial period i.e. 2007. And is now trying to run the settlement via CJ88. Since the financial year/period has already been closed , the system is throwing error as shown below -
"First settle items from previous year in previous year 2007: 400031819/001
Message no. AW624 "
We cannot open the period .
Tell me how to resolve above issue so that user can post the costs.
thanks in advancehi friend.
kb11n cant be used here as this is used only for repostings, and this is not required in this scenario,
i suppose you are getting the error message: AW624 : first settle the items of previous year.
this error comes when you create a wbs and you are using that wbs as a AUC and posting the expences to that AUC and finally you capitalize that asset to final asset through CJ88 settlement.
when the capitalization date lies in the next year where in you have the expences posted to that are in previous year.the system dose not allow you to do that as that period is closed. postings cant happen in the previous period thats closed.to rectify this issue go to OBA5 and give the selection AW and select the number 624 and in online and batch column give W. After giving this settings save it and you will be able to perform the settlement.
this will resolve your issue.
arman
sap fico -
Help needed in getting the previous Quarter Data
Hello folks,
I have this procedure where i have to modify the current procedure in the following manner:
I need to get rid of the variables p_start and p_end so that i cannot see them in the crystal report and include the Frequency in the procedure to get the Data based on the Dates.
and Main requirement is" If the Frequency is Quarterly " it should get the previous quarter Data, if "Frequency is monthly" it should return the previous month data.Can anyone please let me know where shud i make changes. Am including the procedure for refernce. Any help is appreciated
Thanks a millioin,
CREATE OR REPLACE PROCEDURE hcsc_recovery_report_h(report_record in out cr_return_types.gen_cursor,
p_start string,
p_end string)
IS
v_startdate date;
v_enddate date;
BEGIN
v_startdate := to_date(p_start, 'YYYY/MM');
v_enddate := last_day(to_date(p_end, 'YYYY/MM'));
open report_record for
select --distinct r.recovery_id
r.event_id,
r.event_case_id,
c.client_id,
c.client_code,
c.client_name,
b.branch_group_code,
b.branch_group_description,
g.employer_group_code,
g.employer_group_name,
e.client_policy_identifier,
e.date_of_incident,
e.event_type_code,
sum(nvl(r.amount, 0)) as amt_received,
nvl(sum(case
when r.amount >= 0 then
rd.fees
else
rd.fees * (-1)
end),
0) as fees,
ec.close_date, *001* commented
(case
when ec.close_date <= to_date(to_char(v_enddate, 'MMDDRRRR') || '235959',
'MMDDRRRR HH24MISS') then
ec.close_date
else
null
end) as close_date, --*001* added
get_case_value(ec.event_id, ec.event_case_id, v_enddate) as case_value,
nvl(etl.fee_percent_flag, 'N') workmans_comp,
max(to_char(r.recovery_date, 'FMMonthYYYY')) Year_Month,
max(to_char(r.recovery_date, 'YYYYMM')) Y_M,
max(to_date(to_char(r.recovery_date, 'MMYYYY'), 'MM/YYYY')) date_MY
from recovery r,
recovery_detail rd,
event e,
client c,
branch_group b,
employer_group g,
event_case ec,
event_type_lookup etl
where r.event_id = e.event_id
and r.event_case_id = ec.event_case_id
and ec.event_id = e.event_id
and rd.recovery_id(+) = r.recovery_id
and r.recovery_date between v_startdate and
to_date(to_char(v_enddate, 'MMDDRRRR') || '235959',
'MMDDRRRR HH24MISS')
and e.client_id = c.client_id
and g.client_id = c.client_id
and b.client_id = c.client_id
and g.employer_group_id(+) = e.employer_group_id
and b.branch_group_id(+) = g.branch_group_id
and e.event_type_code = etl.event_type_code -- SST 130852 04/14/09
group by r.event_id,
r.event_case_id,
c.client_id,
c.client_code,
c.client_name,
b.branch_group_code,
b.branch_group_description,
g.employer_group_code,
g.employer_group_name,
e.client_policy_identifier,
e.date_of_incident,
e.event_type_code,
ec.close_date,
get_case_value(ec.event_id, ec.event_case_id, v_enddate),
nvl(etl.fee_percent_flag, 'N')
having sum(nvl(r.amount, 0)) <> 0
order by c.client_code,
b.branch_group_code,
g.employer_group_code,
r.event_case_id;
Edited by: user11961230 on Oct 20, 2009 9:02 AMuser11961230 wrote:
1. I want to get rid of the p_start and p_end. So how do i declare the v_startdate and v_enddate in the following part?
v_startdate := to_date(p_start, 'YYYY/MM');
v_enddate := last_day(to_date(p_end, 'YYYY/MM'));I'm not sure what you mean by "declare".
In PL/SQL, "declare" means state (at the beginning of a block) that there will be a certain variable with a certain name (such as v_startdate) and datatype (such as DATE). You're already declaring the variables v_startdate and v_enddate correctly, right before the BEGIN statement.
Declaring a variable is not the same as initializing it, that is, giving it a value for the first time. Your next question seems to be about initializing..
2. where exactly shud i include the logic that u have mentioned. sorry a dumb questionIn place of the two assignment statments that reference p_start and p_end.
3. This time am gonna use frequency instead of report_type so that i will get rid of the p_start and p_end from the procedure.Do you mean you want to pass an argument (called frequency) that tells if you want a quarterly or a mionthly report, just like the variable report_type in my example?
If so, replace report_type in my example with frequency.
I think you want something like this:
CREATE OR REPLACE PROCEDURE hcsc_recovery_report_h
( report_record in out cr_return_types.gen_cursor
, frequency IN VARCHAR2
IS
-- Declare local variables:
v_startdate date;
v_enddate date;
BEGIN
-- Initialize v_startdate and v_enddate, depending on frequency
IF frequency = 'QUARTERLY'
THEN
v_startdate := TRUNC ( ADD_MONTHS (SYSDATE, -3)
, 'Q'
v_enddate := TRUNC (SYSDATE, 'Q');
ELSIF frequency = 'MONTHLY'
THEN
v_startdate := TRUNC ( ADD_MONTHS (SYSDATE, -1)
, 'MM'
v_enddate := TRUNC (SYSDATE, 'MM');
END IF;
-- Subtract one second from v_enddate
v_enddate := v_enddate - ( 1
/ (24 * 60 * 60)
open report_record for
select --distinct r.recovery_id
r.event_id,
and r.recovery_date BETWEEN v_startdate
AND v_enddate
...When you post formatted text on this site (and code should always be formatted), type these 6 characters:
(small letters only, inside curly brackets) before and after sections of formatted text, to preserve spacing.
Edited by: Frank Kulash on Oct 20, 2009 2:37 PM
Changed query to use BETWEEN -
I'm in cycle mode, and 'merge' is clicked in preferences. However, when I record, my previous track data keeps getting overwritten. Does anyone know what I'm doing wrong. Interestingly, I can still see the data in the region.
jamestait wrote:
when I record, my previous track data keeps getting overwritten.
since you didn't specify, are you recording in a single take?
http://www.bulletsandbones.com/GB/GBFAQ.html#multipassrecording
(Let the page FULLY load. The link to your answer is at the top of your screen)
Maybe you are looking for
-
Free Source Softphones Problem
Hi, I'm trying to configure various free source softphones (linphone, ekiga and jitsi) to a cucm, but all of them failed. My question is, how can i configure an account to make them work properly. While trying to see what fails in wireshark, it says
-
Web sharing starts but will not turn off
I have enabled web sharing and been running successfully for a long time, recently upgraded to Lion. The problem I have now is that I can turn Apache on through the Web Sharing prefs but it will not turn off, technically that not true as the instance
-
Submitting InfoPath form via Outlook Address book.
Hi there, Is it possible to have an info path form used so that there is a submit button and the user is able to choose the email address of their choice to have the form sent? Right now I only see the option of configuring a data connection with a p
-
ERROR MESSAGE HOW TO FIX need help
Following are the messages I got after instal CS6 Design Standard. DF013 Failed to delete plist path at /library/Launchdaemons/com.adobe.switchboard.plist seq 20 DW063 Another long failed message DW050 Payload errors during instrall DW050 adobe switc
-
Customising a List Form View without Infopath
Hello, I have a basic form I am using in sharepoint 2013 (standard) that is based off a list. What is the best way to customize the view form page of this list without infopath? Will I have to do it within the code via SPD? Thanks Sean