Last 365 days from a value
Hi,
I need to select last 365 days from the value returning from the below query
(SELECT MAX(MONTH_END_DT) FROM CONTROL.CTL_BATCH_CONTROL).
MONTH_END_DT - its a date column in table CTL_BATCH_CONTROL.
Can anyone help me in this plz.
Thanks
Radha K
Two alternatives:
If you're really only after 365 days ago, even in a leap year:
select col1, col2, ....
from (select col1, col2, ... max(month_end_dt) over () max_month_end_dt
from control.ctl_batch_control)
where month_end_dt >= max_month_end_dt - 365;If you're actually after 1 year ago:
select col1, col2, ....
from (select col1, col2, ... max(month_end_dt) over () max_month_end_dt
from control.ctl_batch_control)
where month_end_dt >= add_months(max_month_end_dt, -12);
Similar Messages
-
Extract data on report between last 30 days from current date.
Hi Experts,
Ealrier i had provided user promt to select the date range, now i need to schedule the report for this i have to set the date between last 30 days from current date.
How can i add this in formaula on record selection.
before:
{pm_process.pm_creation_date} in {@Start Date to UTC} to {@End Date to UTC}
I tried:
{pm_process.pm_creation_date} in CurrentDate() - 30 to CurrentDate()
But this is diplaying me only data of 30th date from current date.
Please advice.Hi Brian,
Thank you!
1. I have not created any function for {pm_process.pm_creation_date} in [CurrentDate() - 30 to CurrentDate()] i am just adding this on Record Selection and its not helping.
2. {pm_process.pm_creation_date} in Last30Days; this is throwing below error.
please advice what to be done? -
In Bex Query day from calday value and sales in prev yr value not come
Dear all
right now i got output like
Sales Sales in Prev Yr
Sales Organization Day From Calday Calendar Day Sales Value Sales Value
1020 Not assigned 05/1/2010 2,013,176.00 INR
1020 Not assigned 05/1/2011 2,945.00 INR
and i want output like base on date 05/01 how to do pl help
Sales Organization Day From Calday Calendar Day Sales Value Sales Value
1020 05/01 05/1/2010 2,945.00 INR 2,013,176.00 INRHi ,
This is possible via customer exit.You can populate day on the bases of your date .
Try this :
WHEN 'tech name of exit var'.
data : v_day type c length 5 ,
v_day_val type c length 5.
IF i_step = 2.
READ TABLE i_t_var_range INTO LS_T_VAR_RANGE WITH KEY vnam = 'date_value u2019.
v_day = LS_T_VAR_RANGE-high+4(4).
concatenate v_day+2(2) '/' v_day(2) into v_day_val .
ls_range-low = v_day_val .
ls_range-opt = 'EQ'.
ls_range-sign = 'I'.
APPEND ls_range TO e_t_range.
Hope this will be helpful .
Regards,
Jaya -
How can I select last 7 days from my table, I use query but it is calculating according to sysdate
It is the data of my talble
DP_DATE
03-APR-10
21-APR-10
22-APR-10
23-APR-10
26-APR-10
27-APR-10
28-APR-10
29-APR-10
30-APR-10
03-MAY-10
04-MAY-10
11 rows selected.
select distinct dp_date
from dailyprice
where trunc(dp_date) between trunc(sysdate-7) and trunc(sysdate)
this query is returning
DP_DATE
29-APR-10
30-APR-10
03-MAY-10
04-MAY-10I want to select last 7 days
26-APR-10
27-APR-10
28-APR-10
29-APR-10
30-APR-10
03-MAY-10
04-MAY-10
kindly guide
regardsHi,
Kame wrote:
with t
as
select 'abcFund' FND , to_date('09-MAY-10','dd-mon-rr') dpdate, 10 price from dual union all
select 'dddFund', to_date('09-MAY-10','dd-mon-rr'), 12 from dual union all
select 'abcFund', to_date('09-MAY-10','dd-mon-rr'), 12 from dual union all
select 'edfFund', to_date('09-MAY-10','dd-mon-rr'), 12 from dual union all
select 'eeeFund', to_date('09-MAY-10','dd-mon-rr'), 12 from dual union all
select 'dddFund', to_date('08-MAY-10','dd-mon-rr'), 12 from dual union all
select 'abcFund', to_date('08-MAY-10','dd-mon-rr'), 12 from dual union all
select 'edfFund', to_date('08-MAY-10','dd-mon-rr'), 12 from dual union all
select 'eeeFund', to_date('08-MAY-10','dd-mon-rr'), 12 from dual union all
select 'eeeFund', to_date('08-MAY-10','dd-mon-rr'), 12 from dual union all
select 'dddFund', to_date('07-MAY-10','dd-mon-rr'), 12 from dual union all
select 'abcFund', to_date('07-MAY-10','dd-mon-rr'), 12 from dual union all
select 'edfFund', to_date('07-MAY-10','dd-mon-rr'), 12 from dual union all
select 'edfFund', to_date('05-MAY-10','dd-mon-rr'), 11 from dual union all
select 'dddFund', to_date('05-MAY-10','dd-mon-rr'), 12 from dual union all
select 'eeeFund', to_date('05-MAY-10','dd-mon-rr'), 12 from dual union all
select 'dddFund', to_date('04-MAY-10','dd-mon-rr'), 12 from dual union all
select 'abcFund', to_date('04-MAY-10','dd-mon-rr'), 12 from dual union all
select 'dddFund', to_date('03-MAY-10','dd-mon-rr'), 12 from dual union all
select 'abcFund', to_date('03-MAY-10','dd-mon-rr'), 12 from dual union all
select 'edfFund', to_date('03-MAY-10','dd-mon-rr'), 12 from dual union all
select 'eeeFund', to_date('03-MAY-10','dd-mon-rr'), 12 from dual union all
select 'dddFund', to_date('01-MAY-10','dd-mon-rr'), 12 from dual union all
select 'abcFund', to_date('01-MAY-10','dd-mon-rr'), 12 from dual union all
select 'abcFund', to_date('30-APR-10','dd-mon-rr'), 11 from dual
)Hot to get my result from this data.What result is that?
Do you mean what you posted in your first message?
I want to select last 7 days
26-APR-10
27-APR-10
28-APR-10
29-APR-10
30-APR-10
03-MAY-10
04-MAY-10The last thing I saw posted
this query will not work in this situation
select dp_date
from ( select dp_date
, row_number() over (order by dp_date desc) rn
from mytable
where rn <= 7ROW_NUMBER will get the 7 most recent rows , whether they all have the same dp_date, 7 different dp_dates, or anything in between.
DENSE_RANK will get the 7 most recent values , whether they come from 7 rows or more.
select DISTINCT
dp_date
from (
select dp_date
, DENSE_RANK () over (order by dp_date desc) AS rn
from mytable
where rn <= 7If you want the 7 most recent calendar days, then use TRUNC (dp_dtate) in the analytic function:
DENSE_RANK () over (order by TRUNC (dp_date) desc) AS rnThis will count (for example) these 3 distinct DATE values:
6-May-2010 07:00
6-May-2010 08:10
6-May-2010 23:59
all as one value. -
Need MDX query to find something like date diff and Date Range for last 10 days
Hi ,
I need two Query .First Query for below;
I have below data in table like.
Cat StartDate EndDate
A 2000-01-01 2000-01-15
B 2000-01-02 2000-01-30
C 2000-01-01 2000-01-31
D 2000-02-01 2000-02-28
A 2000-01-10 2000-01-31
I need if Startdate and Date completes whole one month then set status =1 else 0 using MDX query.
like this ;
Cat StartDate EndDate Status
A 2000-01-01 2000-01-15 1
B 2000-01-02 2000-01-30 0
C 2000-01-01 2000-01-31 1
D 2000-02-01 2000-02-28 1
A 2000-01-10 2000-01-31 1
In second query I need last 10 days from current days like;
Now = 8/20/2014
output will be ;
8/20/2014
8/19/2014
8/18/2014
8/17/2014
8/16/2014
8/15/2014
8/14/2014
8/13/2014
8/12/2014
8/11/2014
8/10/2014
Please help me .
ThanksHi Prajapati,
In your scenario, you can use Properties and Datediff function to achieve your requirement. Since not know the structure of your cube, we cannot give you the esact query.
I have tested it on the AdventureWorks cube, the query below is for you reference.
WITH MEMBER [Measures].[StartDate]
AS
[Employee].[Employee Department].CURRENTMEMBER.PROPERTIES('Start Date')
MEMBER [Measures].[WorkYear]
AS
DATEDIFF('yyyy',[Measures].[StartDate],NOW())
MEMBER [Measures].[Status]
AS
IIF(DATEDIFF('yyyy',[Measures].[StartDate],NOW())>10,1,0)
SELECT {[Measures].[StartDate],[Measures].[WorkYear],[Measures].[Status]} ON 0,
[Employee].[Employee Department].[Employee].MEMBERS ON 1
FROM [Adventure Works]
Results
Reference
http://msdn.microsoft.com/en-us/library/ms144821.aspx
Regards,
Charlie Liao
TechNet Community Support -
Dear all,
I have created a report which calculates the averages for Month to date, year to date, last full working days week and last 4 working days week.
Now I would like to add another feature which is going to show me the records of last 5 rolling days, meaning if today is 11/09/2008, the report should get the data from 10/09/2008 to 04/09/2008 (6,7 skipped because of weekends).
I have tried using the formula like this
{lab_rework.rework_date} in ((date(year(currentdate),month(currentdate),day(Currentdate)-5)))
to
((date(year(currentdate),month(currentdate),day(Currentdate)-1)));
but this didn't work.
I then looked up on the help file and found out Last7Days however I am not sure how to use it to make it work with last 5 working days.
I am trying like this but this isn't working
{lab_rework.rework_date} in ((date(year(currentdate),month(currentdate),last7days-2)))
Any ideas?
Regards
JehanzebNo brian, well yes the above formula does include weekends however, if you modify it like this
{lab_rework.rework_date} in Minimum(last7days)-1 to Maximum(Last7days)-1 and
not(dayofweek({lab_rework.rework_date}) in [1,7])
It would skip the weekends.
However, I am using a workingdays formula which looks for weekends and bank holidays, I needed the code to put it in the start date and end date.
Here is the workingday formula:
WhilePrintingRecords;
Local DateVar Start := ((minimum(last7days))-1);
Local DateVar End := ((Maximum(Last7days))-1);
Local NumberVar Weeks;
Local NumberVar Days;
Local Numbervar Hol;
DateVar Array Holidays;
Weeks:= (Truncate (End - dayofWeek(End) + 1 - (Start - dayofWeek(Start) + 1)) /7 ) * 5;
Days := DayOfWeek(End) - DayOfWeek(Start) + 1 +
(if DayOfWeek(Start) = 1 then -1 else 0) +
(if DayOfWeek(End) = 7 then -1 else 0);
Local NumberVar i;
For i := 1 to Count (Holidays)
do (if DayOfWeek ( Holidays<i> ) in 2 to 6 and
Holidays<i> in Start to End then
Hol:=Hol+1 );
Weeks + Days - Hol;
The above formula sort everything out.
The reason why I didn't post it initially was that it is irrelevant where it needs to go, all I wanted to know was how to get the last 5 days from the currentdate. Rest I knew how to do.
I hope this explains the scenario much better.
Regards
Jehanzeb -
Function module for getting teh last working day of a month.
Hi GURUS,
this is criteria,please help me
if V_T001B- FRYE1 < month entered in selection screen
Then throw the error message
Else
Find the previous period and its last working day from the function module
(i..e Assume entered date as June 2 2009 then
Period 6 -1 = 5.
Pass the month 05 to function module then
Find last working day.
Keep it in a variable (V_LAST_PRD_WRKDAY)
Proceed further.
thanks in advance,
RajeevHi Rajeev,
You can use Function Module LAST_DAY_IN_PERIOD_GET.
Ex:
CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
EXPORTING
i_gjahr = p_gjahr
i_periv = lwa_t009b-periv
i_poper = lwa_t009b-poper
IMPORTING
e_date = s_audat-high.
Regards,
Ravi K -
Get Last Invoice Day and No of days based on Invoice date
Hi,
Can you please provide me logic on how to get the Last Invoice day from the invoice dates .
Also want to the know the no. of days in the month based on invoice date,
Thanks,
Pra.Hi
Getting this information there is few standard functions available. Try to find out & utilize it.
or else you should have to write code in customer exit.
swetha -
Calculate data of last 30 days on basis of sys date
SELECT DT, ITEMCODE, ITEMNAME, QTY
FROM TABLE1In above given query, how i could calculate the QTY details of last 30 days, APR, MAY, and JUNE
As the current month is JULY, in AUG, the Qty details are required for last 30 days (from sysdate), MAY, JUNE, JUL
Please suggest.
Yogesh
Edited by: user12957777 on Jul 28, 2010 3:16 AMHi,
Use CASE expressions to filter data in particular columns:
SELECT SUM ( CASE
WHEN dt >= ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH')
, -3
AND dt < ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH')
, -2
THEN qty
END
) AS third_month
, SUM ( CASE
WHEN dt >= ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH')
, -2
AND dt < ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH')
, -1
THEN qty
END
) AS second_month
, SUM ( CASE
WHEN dt >= ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH')
, -1
AND dt < TRUNC (SYSDATE, 'MONTH')
THEN qty
END
) AS last_month
, SUM ( CASE
WHEN dt >= TRUNC (SYSDATE) - 30
AND dt < TRUNC (SYSDATE)
THEN qty
END
) AS last_30_days
FROM table1
;You can do this with GROUP BY, also, if you want separate rows for each itemname (for example).
I had to guess at some things, such as what you mean by the last 30 days.
If you'd like to post some sample data 9CREATE TABLE and INSERT statements) and the results you want from that data, then I could test this. -
Select last value for each day from table
Hi!
I have a table that stores several measures for each day. I need two queries against this table and I am not quite sure how to write them.
The table stores these lines (sample data)
*DateCol1 Value Database*
27.09.2009 12:00:00 100 DB1
27.09.2009 20:00:00 150 DB1
27.09.2009 12:00:00 1000 DB2
27.09.2009 20:00:00 1100 DB2
28.09.2009 12:00:00 200 DB1
28.09.2009 20:00:00 220 DB1
28.09.2009 12:00:00 1500 DB2
28.09.2009 20:00:00 2000 DB2Explanation of data in the sample table:
We measure the size of the data files belonging to each database one or more times each day. The value column shows the size of the database files for each database at a given time (European format for date in DateCol1).
What I need:
Query 1:
The query should return the latest measurement for each day and database. Like this:
*DateCol1 Value Database*
27.09.2009 150 DB1
27.09.2009 1100 DB2
28.09.2009 220 DB1
28.09.2009 2000 DB2Query 2:
The query should return the average measurement for each day and database. Like this:
*DateCol1 Value Database*
27.09.2009 125 DB1
27.09.2009 1050 DB2
28.09.2009 210 DB1
28.09.2009 1750 DB2Could someone please help me to write these two queries?
Please let me know if you need further information.
Edited by: user7066552 on Sep 29, 2009 10:17 AM
Edited by: user7066552 on Sep 29, 2009 10:17 AMFor first query you can use analytic function and solve it.
with t
as
select to_date('27.09.2009 12:00:00', 'dd.mm.yyyy hh24:mi:ss') dt, 100 val, 'DB1' db from dual union all
select to_date('27.09.2009 20:00:00', 'dd.mm.yyyy hh24:mi:ss'), 150, 'DB1' from dual union all
select to_date('27.09.2009 12:00:00', 'dd.mm.yyyy hh24:mi:ss'), 1000, 'DB2' from dual union all
select to_date('27.09.2009 20:00:00', 'dd.mm.yyyy hh24:mi:ss'), 1100, 'DB2' from dual union all
select to_date('28.09.2009 12:00:00', 'dd.mm.yyyy hh24:mi:ss'), 200, 'DB1' from dual union all
select to_date('28.09.2009 20:00:00', 'dd.mm.yyyy hh24:mi:ss'), 220, 'DB1' from dual union all
select to_date('28.09.2009 12:00:00', 'dd.mm.yyyy hh24:mi:ss'), 1500, 'DB2' from dual union all
select to_date('28.09.2009 20:00:00', 'dd.mm.yyyy hh24:mi:ss'), 2000, 'DB2' from dual
select dt, val, db
from (
select row_number() over(partition by trunc(dt), db order by dt) rno,
count(*) over(partition by trunc(dt), db) cnt,
t.*
from t)
where rno = cntFor second you can just group by
with t
as
select to_date('27.09.2009 12:00:00', 'dd.mm.yyyy hh24:mi:ss') dt, 100 val, 'DB1' db from dual union all
select to_date('27.09.2009 20:00:00', 'dd.mm.yyyy hh24:mi:ss'), 150, 'DB1' from dual union all
select to_date('27.09.2009 12:00:00', 'dd.mm.yyyy hh24:mi:ss'), 1000, 'DB2' from dual union all
select to_date('27.09.2009 20:00:00', 'dd.mm.yyyy hh24:mi:ss'), 1100, 'DB2' from dual union all
select to_date('28.09.2009 12:00:00', 'dd.mm.yyyy hh24:mi:ss'), 200, 'DB1' from dual union all
select to_date('28.09.2009 20:00:00', 'dd.mm.yyyy hh24:mi:ss'), 220, 'DB1' from dual union all
select to_date('28.09.2009 12:00:00', 'dd.mm.yyyy hh24:mi:ss'), 1500, 'DB2' from dual union all
select to_date('28.09.2009 20:00:00', 'dd.mm.yyyy hh24:mi:ss'), 2000, 'DB2' from dual
select trunc(dt) dt, avg(val) val, db
from t
group by trunc(dt), db
order by trunc(dt) -
I am away for a year and have been downloading pictures from my camera - a FUJIFILM EXR compact for the last 15 weeks into files on my mac using IPHOTO no problem...suddenly in the last 2 days I have tried to do this and IPHOTO opens the pictures ok but wont downoad them as they are now JPEG? have I switched something over inadvertently or what - help please!!!! many thanks
sorry maybe Im not making my issue clear...thanks for answering anyway:
over the last years- but 15 weeks specifically I have downloaded photos from my camers card- putting it straight into the apple mac and then opening IPHOTO then i am able to click and put the pics into my folders in IPHOTO but as of 2 days ago - the camera card went in, the pics opened BUT there is an error message which states iphoto cannot save them to file......as they are JPEGS
I can see that others too have had this issue and there are 'answers' but I am a complete novice and cannot understand the answers given and need someone to 'hand hold me' through a step by step this is what you must do....
so hope that now is cleared as to why there is a 'problem'
hope you can still help me thanks for you time -
How to delete files from application server posted in last 30 days
I have some files in application server posted through ABAP program with the below format
\.\.\.abcd_20110209_111209.csv (with date and time). I need to delete those files which was posted in last 30 days through another program. Could you plaese help me to achieve the requirement?There are many ways you can delete/archive files in application servers.
1. Depending on the application server, usually administrators setup delete/archive programs. For e.g. if the application server is a UNIX, then the unix admin will write a script to delete/move older files. - this is the most common approach I've seen.
If you have to achieve this through ABAP then,
1. You can get the script from the server admin and then use that script to create an external system command through SM69/49 and use the function module SXPG_COMMAND_EXECUTE to execute it.
2. You can also look at FM EPS_DELETE_FILE and see if it fits the bill for you.
There are many other possibilities too and each one has its own pros/cons. So you'll have to choose the right one for your requirement. -
HeLLO I AM USING AN IPHONE 5 From Last few days I DON'T KNOW WHAT HAPEND TO MY SET ITS DISTURBING ME A LOT DON'T KNOW WHY BUT I AM NOT ABLE TO UPGRADE ANY APPS BECAUSE WHEN I AM TRYING TO UPGRADE OR DOWNLOAD ANY APP THROUGH WIFI ND 3G BOTH AFTER SOMETIMES IT STOPS DOWNLOADING AND SHows THAT "UNABLE TO DOWNLOAD THIS APP" IT'S SHOWING THIS MESSAGE IN EVERY APP AND ALSO AT ITS DISTURBING ME AT THE TIME OF WATCHING ANY VIDEOS TOO. BECAUSE WHEN I AM TRYING TO WATCH ANY VIDEO IN YOUTUBE IT'S DISTURBING VIDEOS ARE NOT PLAYING ND SOUNDS ARE NOT COMING PROPERLY ND THE IMAGE QUALITY ALSO BECOMES POOR AND THE VIDEO STOPS AFTER SOME TIMES THIS PROBLEM IS HAPPENING AT ALL THE VIDEO ND IT'S HARASSING A LOT. THE SAME PROBLEM IS ALSO HAPPENING TO MY BROTHER'S PHONE TOO.. REQUEST TO APPLE PLEASE ANALYSE AND FIXED THE PROBLEM AS SOON AS POSSIBLE OR ELSE MAYB I NEED TO STOP USING APPLE PRODUCTS. CAUSE IT'S HARASSING MY DAILY LIFE A LOT....
These are user to user forums. You ARE NOT addressing Apple by posting here.
Also, why are you YELLING at us?? Stop using ALL CAPS.
What steps have you done to try and fix the problem? -
Hi, from the last two days my iphone( iphone 4 with ios 5) have very slow to open the apps and very slow when i check the notification window , it taking too much time to open when i tap to down . help me to resolve the issue.
The Basic Troubleshooting Steps are:
Restart... Reset... Restore...
iPhone Reset
http://support.apple.com/kb/ht1430
Try this First... You will Not Lose Any Data...
Turn the Phone Off...
Press and Hold the Sleep/Wake Button and the Home Button at the Same Time...
Wait for the Apple logo to Appear and then Disappear...
Usually takes about 15 - 20 Seconds... ( But can take Longer...)
Release the Buttons...
Turn the Phone On...
If that does not help... See Here:
Backing up, Updating and Restoring
http://support.apple.com/kb/HT1414 -
I recently bought a new i phone 4 as my other one had seen beter days and for the last sevral days have been trying to transfer my photos ect from my old phone to my new one after I've plugged my old iPhone into iTunes to back it up i then plug in my one to transfer it over I've had no luck I've tryed restoring my new phone to the last time i backed up my old files the phone restores but always to its own backup point wen i first connected it to iTunes can anyone help me please?
Since this is the second computer you've had this problem with, I recommend you look for answers on the iPhone forum. My thinking is it is an iPhone issue rather than a computer issue (unless it is some software incompatibility).
Maybe you are looking for
-
Exchange 2013 - Shared Mailbox Permissions
Here is what I am trying to do. I would like to create a shared mailbox in exchange 2013 for time off requests for my employees. I will have the mailbox to be something like [email protected] If an employee is sick or requesting time off, they can em
-
ALV list with count of the table
Dear all, My requirement is i want display the output as alv list along with the count of the table . i got the count but unable to diplay the below the list. please suggest me. Thanks& Regards, RP
-
WSRM Configuration Issues-Need Urgent Help
Dear Experts, we are configuring WSRM between TM 9.0 and ERP 606 systems. we have followed the document from the SAP note 1043195. we have completed the technical configuration. we are facing issues in application configurations. 1. When we hav
-
How to acheive this?? Pls help
Our project has almost completed the development. My client has requested to migrate the database. we are migrating from db2 to db2e. DB2e allows only one database connection.(limitation of db2e) ie i have to close the current connection object befor
-
How do I restore Parallels with all files and programs?
My wife has many "scrapbook" files stored on Parallels. I reformatted my Macbook Pro but now I need to restore Parallels and all those files. Anyone know how to save me from the wrath of Cath? T.