Subtracting from a date

Hello
I am writing a start routine in BI in which i dont want any records which are older than 2 days.
So what i am doing is this
DATA lv_date type d.
    loop at SOURCE_PACKAGE assigning <source_fields>.
      lv_date = <source_fields>-CHANGED_AT - 2.
      if <source_fields>-CREATED_AT <> lv_date.
        delete SOURCE_PACKAGE.
      endif.
    endloop.
Now i have checked that the format of the <source_fields>-CHANGED_AT  is dd.mm.yyyy. this doesnt seem to work. Please can someone suggest me something

Dates are stored internally as yyyymmdd.  Are you sure your changed_at field is also in this format?  SAP uses conversion exits, so what you see in, e.g. LISTCUBE, if you have conversions switched on, isn't what is actually in the database.
Your code should work if the fields are in the correct format - but I think you missed the comparator.  btw - lv_date is not a good name for a variable.  How about lv_two_days_before, or something more meaningful.
DATA lv_date type d.
loop at SOURCE_PACKAGE assigning <source_fields>.
  lv_date = <source_fields>-CHANGED_AT - 2.
  if <source_fields>-CREATED_AT GT lv_date.
    delete SOURCE_PACKAGE.
  endif.
endloop.
Run through the startroutine in debug, and see what the actual values you're getting in lv_date, CHANGED_AT and CREATED_AT
If the dates really are stored in dd.mm.yyyy format, you'll have to convert them to dates, using slicing as Eric suggested, before doing calculations.
matt

Similar Messages

  • Can't subtract from time,date, can only add

    I've been having some trouble with times and dates. I wanted to perform a time correction calculation, that is, to find the difference between two times, then add the difference to a third time as a way of "correcting" it. So, you can add and subtract time-date values in Numbers, and you get the difference in a decimal fraction of days. That is, a day is 1, a half a day is .5, etc. This is the same way Excel does things. So far so good.
    The problem is that, for some reason, you can add to data-time values, but not subtract. For example:
    2/27/2008 9:30:00 PM + .01 = 2/27/2008 9:44:00 PM
    great, no problem, but...
    2/27/2008 9:30:00 PM - .01 = 2/27/2008 9:30:00 PM
    Huh? Why can't I subtract? What's even stranger is that it works of you do this:
    2/27/2008 9:30:00 PM + (-.01) = 2/27/2008 9:15:00 PM
    No that's messed up. Subtraction fails but adding a negative number works? This is a crazy bug.

    Hello
    For the add/substract a constant, my first guess was quite simple.
    The parser is defined to accept the operator + not the operator -.
    If it finds a +, is parse the parameter which may be positive or negative.
    If it finds a -, it treats it as a "not allowed" one.
    Alas it's a wrong description.
    If I try to add 1.1, it works.
    If I try to substract 1.1, the integer part is substracted, not the decimal part.
    So, it can't be a feature but a bug.
    I'm a bit reluctant to report it because I'm afraid that the result would be : disable the tip fooling the beast with a fake addition.
    What's your advice ?

  • Trying to subtract days from a date

    Im trying to subtract days from a date.
    When i use this query:
    select sysdate-:p21_DAYS_OLD from dual;
    it displays the correct date but not in the correct format. It is displaying 12-AUG-09 instead of 08/12/2009.
    I tried this query but i get the ORA-01722: invalid number error.
    select to_char(sysdate,'MM/DD/YYYY')-(:p21_DAYS_OLD) from dual;
    Can someone help me please?
    Deanna

    Dclipse03 wrote:
    Im trying to subtract days from a date.
    When i use this query:
    select sysdate-:p21_DAYS_OLD from dual;Just set the NLS_DATE_FORMAT parameter for your session and execute the above query.
    ALTER SESSION SET NLS_DATE_FORMAT='MM/DD/YYYY'
    /

  • Subtraction of 0Base_line date from 0Clearing date in the Query designer

    Hi
    How to subtract  0Base_line date from 0Clearing date  in query designer??
    I tried using 'Selection' by taking both 0Base_line and 0Clearing date separately in different selection and then subtracting them using formulas. But when i run the query,it is giving error "Use keyfigures in the selection".
    Pls suggest. Itz very urgent.
    Regards
    Deepak.

    Hi
    Thanks for your prompt reply.
    But if any of the date is 'blank' then while subtracting 0Base_line date  from 0Clearing date it is giving some value (like 78,90345).Actually i want *'No of days'* to be displayed.
    Date format is dd/mm/yyyy (12/6/2007)
    Pls help.
    Also i want Grading to be assigned in alphabets(as A, B and C) instead of numbers (1 ,2 and 3). Is there any way in Query designer to achieve such type of grading?
    Pls suggest
    regards
    Deepak

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

  • How to generate a number from two dates

    I am 'new' at this of using Numbers for anything.  What I want to do AND I can't seem to figure it out, is to generate a 'days total' from two dates.  I get paid S.S. on the 2nd Wednesday of each month.  I have X number of dollars to spend.  In order to view each day how much money I have for the rest of the month, I need to be able to obtain how many days are left in the period.  I know what the fixed day is for the end and could key that in.  I want it to be able to take the current day for the calculation without my having to key IT IN each day.  Then I could use that returned number for other functions.  I did look into "Functions" screen on the right hand side, read them several times, tried some but have not succeeded.  Can someone here help this 68 year young man to figure this out?  Thanks

    you can use the function TODAY() to get the date.
    then you can compute a duration (the difference between two dates).  Data/time is a single type of variable in Numbers.  Meaning that a complete date/time value includes both a date and a time.  When you enter one without the other Numbers assumes the other portion.
    you can subtract any two dates to get the duration.
    The format for a date is:
    1/2/2015 12:09A
    2 Jan 2015 12:09A
    a duration would look like:
    3w 4d 6h 15m 45s 76ms
    Three weeks, four days, six hours, fifteen minutes, forty five seconds, seventy six milliseconds
    you can use any combinations of these parts for a duration
    A1
    =TODAY()
    B1
    =EOMONTH(TODAY(),0)
    C1
    =B1−A1

  • 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 Shukla

    The 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.

  • SUBTRACT TIME TO DATE & TIME

    Hi.
    I need SUBTRACT TIME TO DATE & Time.
    Example:
    Date = 08.05.2007
    Time = 01:00:00
    Time_subtract = 2:00:00
    Return of FM:
    Date = 07.05.2007
    Time = 23:00:00
    Do you know any FM?
    Thanks!

    Since the max time difference can be 24 hrs you can reduce that much amount of time from the initial date and then add the difference from the initial date.
    Example : if time difference is to be calculated is 05:00:00 , since this is less than 24 , just add 24 -5 hrs = 19 hrs to the date ( subtract 1 from initial date ) using CONV_UTIL_ADD_DATE_AND_TIME.
    If time to be added is greater than 24 hrs then subtract ( TIME/24 ) from original date and add the difference to date.
    Example : 
    Date = 08.05.2007
    Time = 01:00:00
    Time_subtract = 52:00:00
    Subtract figure = 52/24 = 3 , 52 - 48 = 4.
    Return of FM:
    New date :
    Date = 05.05.2007
    Time = 01:00:00
    Now add 4 to above date using FM to get result.

  • Subtract from Parent in Entity dimension

    Hi all
    I am currently implementing SAP BPC project to replace Hyperion Enterprise. There is an option in Hyperion Enterprise in Entity dimension where you can specify an entity (child or parent node) to be subtracted from its parent rather than the natural way of adding in SAP BPC. I know in SAP BPC, the natural way the hierarchy works is that all the base level nodes are added to its parent level which in turn are added to its parent level and so on and so forth.
    I was wondering if there is a way to accommodate "Subtract from parent" functionality of Hyperion Enterprise in SAP BPC. One way I can think of is to write a script logic to multiply the numbers submitted to that entity by -1 which will make sure that we are subtracting this entity while rolling up.
    Does anyone know of a better way?
    Please let me know.
    Thanks,
    Ameya Kulkarni

    Exactly as Tim says, there's a member property you can add (called UNARYOPERATOR, must use that name, inApp, length 1) that takes a value of one of the following:
    +    (this adds up the member to its parent -- same as if you didn't add this property)
    -     (subtracts this member from its siblings, in computing the parent)
    *     (multiplies it)
    /     (divides it)
    ~    (ignores this member)
    I've never used multiply or divide. The tilde is helpful for skipping the NBV accounts from the fixed assets on the balance sheet, where you can't double-count the original book less accum depreciation, AND the NBV. But every chart of accounts has all those accounts in there.
    This property should probably work in any dimension with a hierarchy. Or almost any -- I'd be surprised if Time would be able to multiply October times November??? But anyway for simple stuff, it should work.
    Or you can use a member formula on the parent, which would be
    OtherChild1 + OtherChild2 - SpecialChosenChild
    A script logic approach will also work, but it means a lot of extra calculations and data, which you should avoid if possible. I think to get the results you want, you'd follow Tim's approach, except the logic needs to post a factor of -2 (not -1) to the shadow member, to get a net result of a negative impact on the parent. A factor of -1 would give a net result of zero.
    Hopefully the unaryoperator or formulaH1 will work.

  • Help with subtracting from two different rows

    Hello everyone..beginner here.. :)
    I have a table wherein I need to subtract two different dates to get the idle time.
    I need to subtract evnt_end from evnt_start to get the difference for the idle time...
    Thanks for your help..
    Here is a sample of the table:
    EVNT_ID..........*EVNT_START*....................*EVNT_END*
    .....1..........6/22/2010 12:34:30 PM..........6/22/2010 6:36:06 PM
    .....2..........6/22/2010 9:58:38 PM...........6/23/2010 4:02:11 AM
    .....3..........6/23/2010 5:10:43 AM...........6/23/2010 11:08:13 AM
    .....4..........6/23/2010 12:22:24 PM..........6/23/2010 6:21:17 PM
    .....5..........6/23/2010 10:29:03 PM..........6/24/2010 4:28:11 AM

    When the evt_start and evnt_end columns of your table are in DATE format,
    you can use
    select (evnt_end - evnt_start) difference_in_days from <yourtable>;you will receive the difference in days.
    To receive the difference e.g. in seconds you could use:
    select (evnt_end - evnt_start)*24*60*60 difference_in_seconds from <yourtable>;or if you also want to see your orignal data:
    select EVNT_ID,
             EVNT_START,
             EVNT_END,
             (evnt_end - evnt_start)*24*60*60 difference_in_seconds
    from <yourtable>;Edited by: hm on 12.10.2010 23:09

  • Subract n days from a date

    Using 2004s service pack 10.  Is there a way to subtract x number of days from a date using a formula?  I saw an earlier post that said to use function module RP_Calc_Date_In_Interval but when I search for this it says it doesn't exist.  Is it called something else in 2004s?  Is the only way to accomplish this using a function module?

    If formula variable does not work and if the "no of days is a fixed number", then next alternative is to have a routine in transformation and make the subtraction.
    Ravi Thothadri

  • Report Builder Wizard and Parameter Creation with values from other data source e.g. data set or views for non-IT users or Business Analysts

    Hi,
    "Report Builder is a report authoring environment for business users who prefer to work in the Microsoft Office environment.
    You work with one report at a time. You can modify a published report directly from a report server. You can quickly build a report by adding items from the Report Part Gallery provided by report designers from your organization." - As mentioned
    on TechNet. 
    I wonder how a non-technical business analyst can use Report Builder 3 to create ad-hoc reports/analysis with list of parameters based on other data sets.
    Do they need to learn TSQL or how to add and link parameter in Report Builder? then How they can add parameter into a report. Not sure what i am missing from whole idea behind Report builder then?
    I have SQL Server 2012 STD and Report Builder 3.0  and want to train non-technical users to create reports as per their need without asking to IT department.
    Everything seems simple and working except parameters with list of values e.g. Sales year List, Sales Month List, Gender etc. etc.
    So how they can configure parameters based on Other data sets?
    Workaround in my mind is to create a report with most of columns and add most frequent parameters based on other data sets and then non-technical user modify that report according to their needs but that way its still restricting users to
    a set of defined reports?
    I want functionality like "Excel Power view parameters" into report builder which is driven from source data and which is only available Excel 2013 onward which most of people don't have yet.
    So how to use Report Builder. Any other thoughts or workaround or guide me the purpose of Report Builder, please let me know. 
    Many thanks and Kind Regards,
    For quick review of new features, try virtual labs: http://msdn.microsoft.com/en-us/aa570323

    Hi Asam,
    If we want to create a parameter depend on another dataset, we can additional create or add the dataset, embedded or shared, that has a query that contains query variables. Then use the option that “Get values from a
    query” to get available values. For more details, please see:http://msdn.microsoft.com/en-us/library/dd283107.aspx
    http://msdn.microsoft.com/en-us/library/dd220464.aspx
    As to the Report Builder features, we can refer to the following articles:http://technet.microsoft.com/en-us/library/hh213578.aspx
    http://technet.microsoft.com/en-us/library/hh965699.aspx
    Hope this helps.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How do I pull just the year from a date?

    I'm trying to pull just the year from a date and cannot figure out how this can be done. I tried the SUBSTR fuction but its not acting how I would expect. What I'm wanting to do is write a condition that says Item Birth Year = Current Year minus 23 I have a calc that figures the age from the difference in the birthdate and current year but I'd really like to just write a condition based just one years. Can this be done?

    Hello
    SUBSTR will only work on a string. To extract portions of a date you need to use the TO_CHAR command.
    To get the year you would use this: TO_CHAR(the_date,'YYYY')
    TO_CHAR takes 2 switches, the date to be manipulated and the portion to be extracted, with the portion in single quotes.
    Once you get used to manipulating dates like this other common pieces are: DD - extracts the day of the month, MON extracts the 3 character code for the month.
    Thus you can use this: TO_CHAR(sysdate,'DD-MON-YYYY') and it will convert the current date, June 7th 2012 to 07-JUN-2012
    Hope this helps
    Best wishes
    Michael

  • How to export a data as an XML file from oracle data base?

    could u pls tell me the step by step procedure for following questions...? how to export a data as an XML file from oracle data base? is it possible? plz tell me itz urgent requirement...
    Thankz in advance
    Bala

    SQL> SELECT * FROM v$version;
    BANNER
    Oracle DATABASE 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE    11.1.0.6.0      Production
    TNS FOR 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    5 rows selected.
    SQL> CREATE OR REPLACE directory utldata AS 'C:\temp';
    Directory created.
    SQL> declare                                                                                                               
      2    doc  DBMS_XMLDOM.DOMDocument;                                                                                       
      3    xdata  XMLTYPE;                                                                                                     
      4                                                                                                                        
      5    CURSOR xmlcur IS                                                                                                    
      6    SELECT xmlelement("Employee",XMLAttributes('http://www.w3.org/2001/XMLSchema' AS "xmlns:xsi",                       
      7                                  'http://www.oracle.com/Employee.xsd' AS "xsi:nonamespaceSchemaLocation")              
      8                              ,xmlelement("EmployeeNumber",e.empno)                                                     
      9                              ,xmlelement("EmployeeName",e.ename)                                                       
    10                              ,xmlelement("Department",xmlelement("DepartmentName",d.dname)                             
    11                                                      ,xmlelement("Location",d.loc)                                     
    12                                         )                                                                              
    13                   )                                                                                                    
    14     FROM   emp e                                                                                                       
    15     ,      dept d                                                                                                      
    16     WHERE  e.DEPTNO=d.DEPTNO;                                                                                          
    17                                                                                                                        
    18  begin                                                                                                                 
    19    OPEN xmlcur;                                                                                                        
    20    FETCH xmlcur INTO xdata;                                                                                            
    21    CLOSE xmlcur;                                                                                                       
    22    doc := DBMS_XMLDOM.NewDOMDocument(xdata);                                                                           
    23    DBMS_XMLDOM.WRITETOFILE(doc, 'UTLDATA/marco.xml');                                                                  
    24  end;                                                                                                                  
    25  /                                                                                                                      
    PL/SQL procedure successfully completed.
    .

  • RFC connection from SAP Data services to SAP ECC

    We have data services set up in linux machine. I am trying to set up RFC connection between data services and SAP ECC.
    From data management console after creating RFC connection i am getting "RFC_bad_connection" error message. Username , password, system number, hostname and client is working from SAP GUI and has all the authorizations. SAP  gateway and service is name is correct.
    Did anyone had similar issue and what was the solution. Do we have start the RFC connection from linux data services machine, i didn't see any sh executable to do so.
    Thanks in advance for helping to solve the RFC connection issue.
    Edited by: gupta sasha az on Dec 19, 2011 7:24 PM

    I am new to SAP and we have just started work on Data Services.
    I wanted to know the complete procedure as in how can I establish a connection between Data Services and ECC.
    Thanks for your help and time.

Maybe you are looking for

  • Can't create a new project in Logic pro . Goes straight to a midi file. Do I shut something down before trying to create a new project

    Can't create a new project in Logic pro . Goes straight to a midi file. Do I shut something down before trying to create a new project?

  • How do I keep logged in on websites with Safari?

    Hi everyone, I have encountered a new problem: Safari can't keep me logged in on some of the sites that I visit daily, like Hotmail, Flickr, iMDB, ebay and Gmail. The browser remembers my usernames & passwords, but I still get logged off automaticall

  • Iweb and godaddy hosting

    So I just purchased iweb and plan to create a website for when i travel to South Africa. Problem is I declined to sign up for .mac because I really only need it for 4 months and don't want to pay $99. Godaddy.com seems to have some better prices but

  • Account Statement issue

    Hi, I'm having a bit of an issue with an Account Statement.  Here is the scenario: Print Program: RFKORD10 Form: Z Copy of standard F140_ACC_STAT_02 *The problem only occurs when I run the statement for <b>past periods</b> in <b>Production</b>. In Q/

  • Mountain lion password

    i am thinking about upgrading my macbook to mountain lion and i was wondering, if i use my apple id to download it, do i have to use my apple id to update it? because i dont want my family having the hassle of using my apple id for updates. And i don