Trunc date fonction for last year

hi all,
how can I get the first of each month of last year,
OK, I explain more,
I have a live database and a datawarhose and I need to purge all data of the month before actual month but of last year for the live DB.
exp:
the sysdate is *2010/12/09* and I should delete all record of table X between *2009/11/01* and *2009/12/01*
how can I use the trunc fonction to do this automaticly
thx a lot for your help, and excuse me for my english
Edited by: 809634 on Dec 9, 2010 11:22 AM

Hi,
To use John's idea in a DELETE statement:
DELETE     table_x
WHERE     dt_col     >= TRUNC (ADD_MONTHS (SYSDATE, -13), 'MONTH')
AND     dt_col     <  TRUNC (ADD_MONTHS (SYSDATE, -12), 'MONTH')
;where dt_col is the DATE column that decides if the row is too old to keep or not.
Do you really need the first condition? What if today is December 9, 2010, and, for some reason, there is still data in table_x from October 2009 as well as Novmber 2009? The statement above would leave all the rows from October 2009, but the following statement:
DELETE     table_x
WHERE     dt_col     <  TRUNC (ADD_MONTHS (SYSDATE, -12), 'MONTH')
;would leave only rows from December, 2009 or later.

Similar Messages

  • Materialstocks for last years

    hi guys,
    I have used the 2LIS_03_BX (Stock Initialization for Inventory Management  
    ) and 2LIS_03_BF (Goods Movements From Inventory Management). When I reviews my queries,
    the Goods Movements are ok.
    I have loaded the data into BW today as written in Whitepaper (How to handle inventory manag...) and "Total quantity stock"
    is also ok. The problem is
    that I can't validate the Stocks for last years. I use the transaction MB5B in R3 and I enter
    the selection date for ex. 30.11.2005 for particular Material and Plant (Stock type is valuated stock).
    I see 5000 PC as stock/value on 01.01.0000, so called "opening stock" which I can't see on BW-Side.
    I use Entry Variables for Fiscal year/Period in the query.
    Which Keyfigure I should use to validate stocks for last years?
    How I can view the stocks for last years in BW and compare it with R3 TR MB5B?
    Thanks for assistance.
    Regards,
    Moha
    [email protected]

    For last one month I am facing problem in watching online videos on my iPod touch. It is not opening or can say loading the online videos. Earlier it used to be work absolutely fine. Any solution for my problem.

  • How to Run ebs adaptor data load for 1 year using DAC

    Hi,
    iam trying to Run the ebs adaptor data load for 1 year for procurement and spend ,Please let me know the parameter to set in DAC.
    last extract date is set as Custom Format(@DAC_SOURCE_PRUNED_REFRESH_TIMESTAMP
    Thanks

    You need to set $$INITIAL_EXTRACT_DATE to a year ago. The LAST EXTRACT DATE is something used for incremental loads and you do not manually set that.
    if this helps, mark as correct or helpful.

  • Error : No data read for fiscal year 2006 (error  FDBL020)

    Hello !
    I have a problem in transaction FS10N, when i am trying do execute appear the error: No data read for fiscal year 2006 (error  FDBL020), i tried applying the note 302263 (deleting the attributes of programs)but the attributes has been deleted. Anybody know a solution ?
    Thank´s
    Claudenir

    hi,
    i mean to check, whether there are items posted in that fiscal year.
    Andreas

  • No data read for fiscal year 2011

    In ECC6, after posting document in FI, I wan to check balances with T-Code FS10N and Enter GL account in which document entry supposed to be recorded. But when I execute it getting message in Information window " NO data read for fiscal year 2011 (Long text)
    what does it mean? Appreciated explanation

    I did saved the entry and then got message, when I was trying to display document no?
    error message "document no 200000003 sony does not exists in fiscal year 2011"
    when I was trying to see display of GL account
    Got message " NO data read for fiscal year 2011"
    when I was trying to make document reversal of document no: 200000003
    Got message "document no 200000003 sony does not exists in fiscal year 2011"
    My document type is SA and reversal document type is Ab, No. range for this document is in fiscal year 2011.
    I really confused where is my config. went wrong?
    suggestion and expert opinion are expected and appreciated.

  • No international data plan for one year-???

    Here is the background.  I moved over to Verizon about 4 months ago from Alltel.  I did this because I wanted to be able to have a blackberry with international BBm'ing.  I did not go with ATT because there coverage was spotty in my area.  Since the move, I would say my Alltel coverage was 3x better then the cuurent verizon in my house even with the network extender ( BB don't work well with network extender compare to droids, according to the VZW reps).  I did not stay with Alltel because they did not have the storm2.  I needed 6 lines and a mifi and the local verizon rep told me no problem that they could do one primary line and 5 additonal line plus the mifi but after I signed up they realized that I maxed out at 5 lines on one account and they made me make my 6th line a primary line and then added the mifi to the 2nd account.  More costs per month.  Within a month of having my VZW account, one of my kid went to China and we were able to add the international data plan for her trip so she could BBM us.  No problems.
    Here is the problem.  I am going abroad in 2 days and would like to put the international data plan on 2 phones for the trip.  The rep says he cannot do becaue the polciies have changed with the "xerox" buyout and they won't let me do it for the following reasons.
    1.  I have not had my phones for more than one year even though I paid a deposit on them
    2. I have 7 lines on one account- not true I have one account with 1 primary line and 4 additional lines and I have another account with one primary line and the mifi account.  they are all billed on the same statement.  If they are all "one account" then VZW owes me a refund on the 2nd account's primary line as they cannot have it both ways. 
     We came to verizon for the purpose of BBM’ing when going international and now we cannot use it.  I am paying over $500.00 a month and have not been late on any payments, paid a deposit on the phones, am paying for 2 primary lines and did this a few weeks ago for my daughter and now I cannot add the international option again for a week of vacation abroad?  This is really upsetting and pretty much the last straw if it does not get resolved before this trip.  I should have stayed at Alltel or went to ATT and got an I phone because this is no better.    The rep I talked too was bedeviled by this policy and went two levels up in supervisors and was denied.  They are supposed to call me to resolve this issue tonight or in the morning. 
    {word filter avoidance}

    Update:
    I got a call from my local rep at the store where I bought all the phones.  She said they called corporate and all blocks on my international data plan have been removed?  I will stop by this afternoon and confirm that it has all been done???? I still cannot believe how many hoops I will have had to jump through to get this done as it was done 2 months ago, if it actually gets done.
    If it does not get done then i will be requesting to be let out of my contract for breach of contract on Verizon's part as it was never told to me that I could not have international service for one year after signing up and we were able to do it within a month of signing up initially.  Will post updates

  • Posting Depreciation for last year in the current year

    Hi,
    We have a situation in which we have to book depreciation for assets that were put into service since last year in the current year. The depreciation expense was accrued and reported when the year was closed out. However SAP wouldnt allow us to calculate the depreciation for anything before 01/01/2009. The assets were put into service in July of last year and hence we need to post 6 months of depreciation that we accrued last year in this posting period (when we will be capitalizing those assets). How do we go about doing this?
    Here is what we tried:
    1. Manual Depreciation: Doesnt work. The depreciation key we are using (LINA) doesnt allow manual depreciation
    2. Changing the ordinary dep start date: You can change this date to last year but it wont calculate the depreciation from last year. It just starts the useful life from last year. The depreciation that is being caught up starts from 01/01/2009
    3. Unplanned Depreciation: This is not an option because it goes to a different G/L account. The client wants it to be in the regular depreciation expense account only.
    Any suggestions?
    Thanks!

    Hi,
    So far my knowledge goes there is no way wherein you can capitalise assets in currnet year and account for dep from the previous year unless you go for post capitalisation vide ABNAN.Let me try to explain it by the following example.
    FY: April to March
    APC 10000/
    Rate od dep   10%
    Ord dep Start   01.10.08.
    Asset capitalisation date 01.10.08 but posted in the system on,  say   01.04.09.
    Line items for ABNAN
    70   Asset A/c     10000
    75   Acc Dep                          500(on 10000 @ 10% for 6 months)
    50 Rev for post capitalisation 9500.
    FB60 Line items.
    31   Vendor Account       10000
    40  Prior per dep                   500
    40  Rev from post capitalisation  9500.
    I do hope you will be able to clear your confussion.
    With best wishes
    Monoj
    Edited by: MONOJ SARKER on Aug 5, 2009 12:11 PM

  • How to get YTD sale for Last year In OBIEE 11g

    Hi All,
    I have a fact table for Sale_Amt with doc_date wise details. It is connected to Simple time_dimension table based on Date_ID(Number) field. The time_DIm Hierarchy is set on Year, Quarter, Month fields of the time_dimension table.
    One of my reporting requirement is to show show YTD sales and Last Years YTD sales.
    e.g, If user select 23 Jul 2013 as the date parameter, I need to show 1-Apr-2013 till 23 Jul 2013 Sales in YTD column and 1-Apr-2012 till 23 Jul 2012 Sales in Year_Ago_YTD column. I am able to get YTD sales but unable to derive at Year_Ago_YTD sales figures.
    Finacial Year Start from 1st April till 31 March.
    Any Help on this will be appriciated.
    Thanks.
    Narendra Shetty.

    Narendra,
        You can make use of the below two functions to get the year ago dates. You can replace current_date with a presentation variable that stores the date parameter that user selected.
    TimestampAdd(SQL_TSI_YEAR,-1,TIMESTAMPADD(SQL_TSI_MONTH, 3,TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE))) - It will display previous year's first day of fiscal year (since I passed current_date, it gives you 1st april 2012)
    and
    TimestampAdd(SQL_TSI_YEAR,-1,current_date) - Same Day Last year
    Pls mark correct/helpful.

  • Dates -- Pulling the last year data!, which should'nt be the case.

    Need some basic SQL Help ..
    Iam supposed to pull the data based on a date column(end_time) -- Yesterday 3PM untill Today's 3PM.
    Iam getting last year's data too in additon to Current Data.
    Where am i comparing wrong??
    SELECT a.*
    FROM table a
    WHERE TO_CHAR (a.action_end_time, 'MM/DD/YYYY HH24:MM:SS') >=
    TO_CHAR (SYSDATE - 1, 'MM/DD/YYYY')
    || ' 15:00:00'
    AND TO_CHAR (a.action_end_time, 'MM/DD/YYYY HH24:MM:SS') <=
    TO_CHAR (SYSDATE, 'MM/DD/YYYY')
    || ' 15:00:00'
    ORDER BY a.end_time;

    Date math, 1 = 1 day 1 / 24 = 1 hour, trunc with no date format gives midnight
    Try this.
    select a.* from table a where
      a.action_end_time between trunc(sysdate) + (15 * 1 / 24)
                            and trunc(sysdate - 1) + (15 * 1 / 24) In your example you are comparing strings, not dates.

  • Hyperion Strategic Finance - Formula for last years average

    Hi all,
    I am starting developing a model in HSF.
    At first glance the tool is perfect for our needs but unfortunately I get stuck sometimes with the formulas.
    I am trying to show last year's average on a forecast account.
    The problem is that apparently I cannot blend relative (-1Y) and absolute (@since(Jan)) parameters.
    Does anyone of you know how to do this?
    Your help is much appreciated!
    Thank you
    Mike

    camera_jen wrote:
    ngarver586 wrote:
    Seems ridiculous and annoying to me. Not sure what rate they were offering but I'm sure you could find likewise somewhere else. Have you tried?Not yet.  My lease is up in June of 2016 so I have a while, I just had them pull my credit to check and get ahead of any issues they may have.  The past issue was I didn't have enough credit.  Now it's that I opened multiple credit lines in 6 months.  They didn't even offer an interest rate, just flat out said that based on what they see they will not offer me financing at all.  And it seems inconsistent because I know someone who was financed through them and that person is a train wreck.In regards to trainwrecks, yeah it blows my mind when things like that happen. I see it all the time with credit cards. I would shop around quite a bit and see what you can come up with. What rate do you require for a comfortable payment?

  • Assign Assets value date bydefault as last year doc date.

    My scenario is :
    Assets Purchased date is 01-02.2009(which comes in last year) & we are posting it today.
    I keep default value date as doc date.
    But it comes by default  when i post in same fiscal yr.When i post with last yr doc date,then it takes today date as value date.
    How to keep last yr doc date as value date?

    Thanks.
    I have kept the rule as 3-prime & 4-Alternative.
    Still i m not getting .
    Posting date       01.07.2009
    Document date : 01.02.2009
    So i want Valie date as 01.02.2009.
    I think this rule is applicable in same yr of Posting & Value date only.
    When i use date within same yr then this rule getting apply,but when i used different fiscal yr then it takes Posting date as value date.
    So how to Keep value date as doc dt( which is in last yr) ?

  • Can't find data usage for last 6 months in Analyze My Plan

    I have accounts with Spring and Verizon.  On the Sprint account page, I can easily see my data usage for the last 12 months, both on system data and roaming data (I have been notified of exceeding the monthly roaming data cap).
    On the My Verizon website, I can see the last 6-months of Overview billing, but when I click on the data usage, it says there is no data available.
    Where can I see the last 12 months of my data usage for my MiFi device?

    Mooring10 wrote:
    Only 90 day?  that seems a mere pittance in the days of NSA data collection.  My Sprint account shows me on system and roaming data for the last 12 months.  I can't ascertain any seasonal trends to my data use with only 90 days.  I'm sure you are collecting and saving more than 90 days--common, its just a programming change to show more data.  Even my utilitiy bills show me that last 12 months of usage.  Please consider revising your website to display the last 12 months of on system, roaming, and total data usage.  Thank you.
    Your bills which are available for 18 months show the total usage amount for the billing cycle of each bill.

  • How can i get my call history for last year? Skype...

    Hi,
    I am trying to sponser my wife to Canada. They are asking for communication details of last year. I tried on this site and i could only get the details of last 6 months.
    I am really in a hurry since they want me to send them with in two weeks.
    Highly appriciate if someone can help me.
    Thank you. 
    CA

    Hi, Praveensam2, and welcome to the Community,
    Please note that call history is available only on the computer or laptop where the Skype files are located.  You might see if the chat logging freeware software offered by NirSoft may be of use to you.  http://www.nirsoft.net/utils/skype_log_view.html
    Regards,
    Elaine
    Was your question answered? Please click on the Accept as a Solution link so everyone can quickly find what works! Like a post or want to say, "Thank You" - ?? Click on the Kudos button!
    Trustworthy information: Brian Krebs: 3 Basic Rules for Online Safety and Consumer Reports: Guide to Internet Security Online Safety Tip: Change your passwords often!

  • 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 .
    Thanks

    Hi 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

  • Counting date transactions for last six months

    Post Author: crystalrook
    CA Forum: Formula
    Any help is greatly appreciated.  I am running Crystal XI.
    I have an order field (PurchaseOders.PODatePlaced) for each item. There can be multiple orders in the same month for each item of course.  I would like to COUNT each  PurchaseOders.PODatePlaced based on the month it was purchased for the last six months from a date parameter.
    My table looks like this"
    Item            PODatePlaced
    1234           11/12/2007
    1234            11/20/2007
    1234            10/15/2007
    1234            9/30/2006
    1234            12/5/2007
    1234             12/6/2007
    I am trying to get the results to read as follows (only for the last 6 months):
    Items          December         November     October
    1234               2                      2                1
    Thanks for your help

    Post Author: crystalrook
    CA Forum: Formula
    I am adding a cross tab to an existing report so many of the fields are already in the report. I would like to only add the month fields and a count of the transactions. Can this be done?  In the group options how can I tell it to only use the last six months reguardless of activity for the month.  Current results are giving every date as a column.  Can I only get the months to be columns?
    Any suggestions?

Maybe you are looking for