Split with date arithmetic

Hi,
I have the following input [test 01-Jan-10 14] and wanted to split the text so that I would get 01-Jan-10 + 14 days? Is this possible using sql?
Thanks!
Edited by: user11922215 on Aug 16, 2010 3:23 PM

if the format is always same and if data is never bad and is always identical, then it can be
SQL> WITH t AS
  2       (SELECT 'test 01-Jan-10 14' dt
  3          FROM DUAL)
  4  --
  5  SELECT   TO_DATE(SUBSTR(dt, INSTR(dt, ' '), 10), 'dd-mon-yy')
  6         + TRIM(SUBSTR(dt, INSTR(dt, ' ', 1, 2))) dt
  7    FROM t;
DT
15-JAN-10and even you hard code as the other user mentioned after my post
SELECT   TO_DATE(SUBSTR(dt, 6, 10), 'dd-mon-yy')
       + SUBSTR(dt, 16) dtEdited by: Clearance 6`- 8`` on Aug 16, 2010 6:45 PM

Similar Messages

  • Initialize Delta Process with Data Transfer - Split the job in two/three

    Hello,
    I am trying to load master data into BI (DEV) and there are 700,000 master data records in my source system. When I tried to load Initialize Delta Process with data transfer, at some point (after 300,000 records) my load failed in source system and job log I found that this issue "ABAP/4 processor: TSV_TNEW_OCCURS_NO_ROLL_MEMORY"
    When I informed this issue to BASIS consultant, they suggest me to split the job in 3 (Three). My question: how can I split the job in three? I can do one Initialize Delta Process load and followed by delta load.
    Regards,
    Md

    Hi Md.
    Even at Infopackage level you can reduce the number of records per package.
    Go to Infopackage Schedular Menu -> DataS. Default Data Transfer. you can reduce the Maximum size of a data packet in kByte.
    Regards,
    Pratap Sone

  • Help needed with SQL to split huge data into two excel or text files.

    Hi,
    I have a table which has around 1850000 records. I want to split the data into two sets and import the data in .txt or execl file.
    How can i break upthe records using rownum or any thing
    select * from tablename where rownum<940000 fetched some records
    but
    when i gave select * from tablename where rownum>940000 it was not fetching records.
    Guideme

    when i gave select * from tablename where rownum>940000 it was not fetching records.try this
    select * from (select tablename.*, rownum rn from tablename) where rn >940000

  • How to export the text edit data to excel file without splitting the data in excel file?

    how to export the text edit data to excel file without splitting the data in excel file?
    I have a requirement in SAP HR where in the appraiser can add comments in the area given and can export that to excel file. Currently the file is getting exported but the comments getting split into deifferent rows.
    I want the entire comment to be fit in one row.
    Please help.
    Thank you

    Hi,
    if your text edit value is stored in 'lv_string' variable.
    then before exporting the value to excel you have to remove CL_ABAP_CHAR_UTILITIES=>NEWLINE
    that is '#' from the variable lv_string.
    for that use code some thing like this.
    REPLACE ALL OCCURRENCES OF CL_ABAP_CHAR_UTILITIES=>NEWLINE in lv_string WITH space.
    I think this will do the trick.

  • How to split the data based on one column

    Dear All,
    I have the table data like this.
    type quantity revenue_mny count country
    a 10           10          2 India
    a 20          12          3 India
    b 30          15          1 India
    a 35          20          2 US
    b 20          10          1 US
    b 60          15          1 US
    I woulkd like to split the date based on type column.
    For each country, for Type "a" get the sum of revenue count quanity ans same for b
    and all shuld come in on row for each country.
    output should be like
    country revenue_mny(For a) quantity(for a) count(For a) revenue_mny(for b) quantity(for b) count(For b)
    India 22 30 5 15 30 1
    US 20 35 2 25 80 2
    I tried the below query . its not splittng the date for each country in one row.
    select country,
    sum(case when type='a') then revenue_mny else 0 end ) revenue_mny_a,
    sum(case when type='b' then revenue_mny else 0 end ) revenue_mny_b
    sum(case when type='a' then quantity else 0 end) quantity_a,
    sum(case when type='b' then quantity else 0 end) quantity_b from
    test
    group by country
    Please need your helo

    Like this?
    with t as
    select 'a' type, 10 quantity, 10 revenue_mny, 2 cnt, 'India' country from dual union all
    select 'a', 20, 12, 3, 'India' from dual union all
    select 'b', 30, 15, 1, 'India' from dual union all
    select 'a', 35, 20, 2, 'US' from dual union all
    select 'b', 20, 10, 1, 'US' from dual union all
    select 'b', 60, 15, 1, 'US' from dual
    select country,
    sum(case when type='a' then revenue_mny else 0 end ) revenue_mny_a,
    sum(case when type='a' then quantity else 0 end) quantity_a,
    sum(case when type='a' then cnt else 0 end) cnt_a,
    sum(case when type='b' then revenue_mny else 0 end ) revenue_mny_b,
    sum(case when type='b' then quantity else 0 end) quantity_b ,
    sum(case when type='b' then cnt else 0 end) cnt_b
    from t
    group by country;result:
    COUNTRY  REVENUE_MNY_A QUANTITY_A CNT_A REVENUE_MNY_B QUANTITY_B CNT_B
    India    22            30         5     15            30         1
    US       20            35         2     25            80         2Or you can do it with a decode instead of case. The result will be the same:
    with t as
    select 'a' type, 10 quantity, 10 revenue_mny, 2 cnt, 'India' country from dual union all
    select 'a', 20, 12, 3, 'India' from dual union all
    select 'b', 30, 15, 1, 'India' from dual union all
    select 'a', 35, 20, 2, 'US' from dual union all
    select 'b', 20, 10, 1, 'US' from dual union all
    select 'b', 60, 15, 1, 'US' from dual
    select country,
    sum(decode(type,'a',revenue_mny,0)) revenue_mny_a,
    sum(decode(type,'a',quantity,0)) quantity_a,
    sum(decode(type,'a',cnt,0)) cnt_a,
    sum(decode(type,'b',revenue_mny,0)) revenue_mny_b,
    sum(decode(type,'b',quantity,0)) quantity_b,
    sum(decode(type,'b',cnt,0)) cnt_b
    from t
    group by country;(I changed tablename from TEST to T and columnname from COUNT to CNT, because you should not use reserved words as tablename or columnname.)
    Edited by: hm on 09.10.2012 06:17

  • Problem with data type 'STRING'

    Hi All,
    I have created a table named as zproject_mat and there is a field 'LONG_D' for long description and its size is not limited, so i used 'STRING' data type for this field. But the problem is: when i use this field in where condition with 'SELECT QUERY'  in my abap program , it throws me an error..'The field long_d is a long string , so it cannot be used in WHERE, ON, or having conditions'.
    Can anyone help me regarding this. I dont know which data type will be suitable in both conditions, LONG DESC AND SELECT QUERY.
    Regards
    Rahul

    Hi Rahul,
    As mentioned your Table name is 'zproject_mat' and there is a field 'LONG_D'.
    The field 'LONG_D' will have a Data Element associated with it. Create a new input Data Element & Domain 'ZLONG' of Type CHAR with Length = 1100. This will used in the code.
    For the Table 'zproject_mat', you need to need to break up your field as 'LONG_D1', 'LONG_D2', ........, 'LONG_D5' with Data Element as 'BAPI_MSG'.
    To INSERT data in table:
    In your code, you need to write your logic where the field 'LONG_D' is SPLIT into 5 words and saved in your table against the 5 fields.
    To SELECT data from table:
    In your code, again you need to write your logic where the field 'LONG_D' is SPLIT into 5 words as abaove and pass them to your SELECT query...
    SELECT SINGLE *
    FROM zproject_mat
    INTO wa_zproject_mat
    WHERE long_d1 = v_split1
          AND long_d2 = v_split2........
         AND long_d3 = v_split3.
    The limitation of a table length is 4096 whereas of a field is 255 to make it RFC compatible. Table/Structure fields that are passed via RFC for integration have this limitation and to maintain database standards, these limitations exist.
    Hope this helps.
    Regards,
    Pranav.

  • Invoice split with examples

    Hello guru
    can any one send the details regarding invoice split with examples
    [email protected]
    thanks in advance

    hi,
    As a rule, the system combines into one billing document all transactions for the same customer, default billing date and sales organization.
    If data from the related reference documents differs in the header fields of the billing document, the system will automatically split the invoice.
    An order contains terms of payment at header as well as item level. These are stored only at header level in the billing document, however. If there are different terms of payment in the reference documents, an invoice split will always be made.
    If data from the related reference documents differs in the item fields of the billing document, the system does not split the invoice.
    The order basis is stored at header level in the order and at item level in the billing document. The system does not split the invoice. If you require an invoice split, you must first define the appropriate split requirements in Customizing for copying control. Copying control depends on the following criteria:
    Billing Document Type
    reference document type (i.e. type of order, delivery or billing document on which the sales document is based)
    item category in the reference document
    You can also display a split analysis to discover why an invoice split has occurred.
    Thanks
    Sadhu Kishore

  • How to do a WHERE cause with dates

    Hello!
    I'm new to Oracle and I'm wondering how to select records like this: WHERE (YEAR(SOME_DATE) > YEAR(NOW()) - 3).
    YEAR in T-SQL returns an Int, so I can do math pretty easy. How would one do this with TO_CHAR? Do I have to cast to an Int or what?
    Thanks!

    Hi,
    So, when you do this in 2009, you want to know if dt is in 2006 or later, and when you do the same thing in 2010, you'll want to know if dt is 2007 or later; is that it?
    Date arithmetic in Oracle was designed for counting days. For dealing with larger units, ADD_MONTHS is the best thing.
    SYSDATE is today's date
    ADD_MONTHS (SYSDATE, -36) is exactly 3 years ago
    TRUNC (ADD_MONTHS (SYSDATE, -36), 'YYYY') is the beginning of the year 3 years ago, so
    WHERE   dt >= TRUNC (ADD_MONTHS (SYSDATE, -36), 'YYYY') will be TRUE if dt is any time in 2006 or later, given that it is currently 2009.
    By not applying any functions or date arithmetic to dt, we allow the optimizer to use an index on it.

  • Problem populating html form fields with data from database.

    I'm using a straight forward piece of code to populate a form with data from a database, to create and 'edit record' page. The code is as follows;
    TO RETREVE THE DATA FROM THE DATABASE;
         $query = "SELECT * FROM $table WHERE newsletter_id = '$newsletter_id'" ;
         mysql_select_db($database) ;
         $result = mysql_query($query, $connect);
         $numRows = mysql_num_rows($result);
         $dbnewsletter_title = mysql_result($result,$i,'newsletter_title');
    TO POPULATE THE FORM FEILD;
    <tr>
              <td width="140"><p class="admin">Newsletter title</p></td>
              <td><input name="newsletter_title" type="text" <? print "value=$dbnewsletter_title";}?> /></td>
            </tr>
    However, when I view the page, the string shows in the text feild, but seems to be split at the point of the first space. So basically only the first word of the string shows in the text field. If I try to print '$dbnewsletter_title' outside of the table, the string is shown in full as it should be.
    Does anyone know what is causing this problem?
    Many Thanks

    Put the value in quotes:
    <?php print "value='$dbnewsletter_title'"; ?>

  • Script or operation to split a date and time channel into two channels

    Hi There,
    I have a channel that contains a range of dates and times.
    I would like to split that channel into two channels - one with date and one with time.
    Any suggestions?

    Sorry:    Here is the attachment......
     and Sample of the data
    Comment:
    Date
    Time
    AIR TEMP
    AIR TEMP SP
    TAC PTC
    Load Temp
    Channel 4
    UUT Front TC
    1/20/2015
    12:30:05
    80.3
    79.3
    59.4
    0
    0
    62.9
    1/20/2015
    12:30:11
    80.1
    79.3
    59.5
    0
    0
    63
    1/20/2015
    12:30:17
    80
    79.3
    59.6
    0
    0
    63
    1/20/2015
    12:30:23
    79.9
    79.3
    59.7
    0
    0
    63.1
    1/20/2015
    12:30:29
    79.7
    79.3
    59.7
    0
    0
    63.2
    1/20/2015
    12:30:35
    79.7
    79.3
    59.8
    0
    0
    63.4
    1/20/2015
    12:30:41
    79.6
    79.3
    59.9
    0
    0
    63.4
    1/20/2015
    12:30:47
    79.6
    79.3
    60
    0
    0
    63.5
    1/20/2015
    12:30:53
    79.5
    79.3
    60
    0
    0
    63.5
    1/20/2015
    12:30:59
    79.5
    79.3
    60.2
    0
    0
    63.6
    1/20/2015
    12:31:05
    79.6
    79.3
    60.3
    0
    0
    63.7
    1/20/2015
    12:31:11
    79.6
    79.3
    60.3
    0
    0
    63.7
    1/20/2015
    12:31:17
    79.6
    79.3
    60.5
    0
    0
    63.8
    1/20/2015
    12:31:23
    79.7
    79.3
    60.6
    0
    0
    63.9
    1/20/2015
    12:31:29
    79.7
    79.3
    60.7
    0
    0
    64
    1/20/2015
    12:31:35
    79.8
    79.3
    60.8
    0
    0
    64.1
    1/20/2015
    12:31:41
    79.8
    79.3
    60.9
    0
    0
    64.3
    1/20/2015
    12:31:47
    79.8
    79.3
    61
    0
    0
    64.4
    1/20/2015
    12:31:53
    79.7
    79.3
    61.1
    0
    0
    64.4
    1/20/2015
    12:31:59
    79.7
    79.3
    61.2
    0
    0
    64.5
    1/20/2015
    12:32:05
    79.7
    79.3
    61.3
    0
    0
    64.6
    1/20/2015
    12:32:11
    79.6
    79.3
    61.4
    0
    0
    64.7
    1/20/2015
    12:32:17
    79.6
    79.3
    61.5
    0
    0
    64.8
    1/20/2015
    12:32:23
    79.6
    79.3
    61.6
    0
    0
    64.8
    1/20/2015
    12:32:29
    79.5
    79.3
    61.6
    0
    0
    64.8
    1/20/2015
    12:32:35
    79.5
    79.3
    61.7
    0
    0
    64.8
    1/20/2015
    12:32:41
    79.5
    79.3
    61.8
    0
    0
    64.9

  • FM for splitting the date

    Hi Everyone,
    I need an FM to split the Date into days , month and year...
    can anyone help me out.
    Points will be rewarded.
    Regards,
    Syed

    Hi Syed,
    When we can do something with the code you can write the code. Since the sy-datum is anyhow stored in YYYYMMDD format you can split it by writing a small piece of code like this :
    data :
      w_day type i,
      w_month type i,
      w_year type i.
    w_day = sy-datum+6(2).
    w_month = sy-datum+4(2).
    w_year = sy-datum(4).
    write :/ 'Day    :  ', w_day,
           /  'Month :  ', w_month,
           /  'Year    :  ', w_year.
    Regards,
    Swapna.
    Edited by: NagaSwapna Thota on Jul 8, 2008 11:07 AM

  • Split Spry.Data and Spry.Data.Region from SpryData.js?

    I don't like Spry.Data.Region or anything like Spry.*.Region because it make hard to customize using javascript.
    But Spry.Data with Observer / Notify feature is great one. In fact, using SpryData.js, I can write my own "render html object" easier.
    SrpyData.js is big (127KB) even when compressed, it is still 65KB. That why, needed split Spry.Data and Spry.Data.Region from SpryData.js so who want to use Spry.Data only like me will get smaller trafic.
    I've tried remove all Spry.Data.Region content in SpryData.js. Surprise, some in Spry.Data call to Spry.Data.Region >>> Design have problem.
    Anyone can help splitting them?

    Found this in the archives:
    <div spry:if="{ds_RowCount} == 0" class="trigger" style="display:none"></div>
    Basically a hack to point the tooltip to a hidden div so no errors are thrown.

  • Help with Date n time!!

    I am having problems with time and dates.
    I am reading records from the database which is in time format (hh:mm) but when I am reading those records it is giving me this; like:
    <b>10:00 AM in the database would be something like this</b>
    <b>12/31/1899 10:00 AM some junk.</b>
    How would u convert time in the same format I have in the database.
    How would u add time.Please help!!
    My project is at halt b/c of this..

    I am assuming that you have read the link that I've posted but don't understand what it said....So, here is a code snipet that shows you how you can convert the time string and the date-and-time string:
    try {
       SimpleDateFormat df=new SimpleDateFormat("hh:mm a",Locale.getDefault());
       Date date=df.parse("10:00 AM");
       System.out.println(date.getTime());
       df=new SimpleDateFormat("MM/dd/yyyy hh:mm a z",Locale.getDefault());
       date=df.parse("12/31/1999 10:00 AM CST");
       System.out.println(date.getTime());
    } catch (Throwable e) {}Note that date.getTime() returns a long integer representing number of milliseconds (in the case where a date is involved, the number starts at 0 for 1/1/1970 -- a negative number is for a date prior to 1/1/1970). To find seconds, divide date.getTime() by 1000, to find minute, divide by 60000, etc....)
    To answer your other problem, you can subtract one date.getTime() value by another. Unfortunately Java developers didn't see fit to provide classes to do date arithmetic.
    Hope this answer your questions.
    V.V.

  • Filling Dyanamic Internal table with data

    Hi All
    I have a following requirement.
    1.. I have internal table with 1 text field of length 1000, this is field with data uploaded from text file having data tab seprated
    2. I have a dyanamic table in which i have to fill the using the above internal table  splited by tab seprated into the corresponding fields of dyanamic table.
    please suggest some solution for the above.
    thanks
    bobby

    Hi Martin,
    But How to assign to dyanmic table fields if we are using
    split t_intab at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into .
    where t_intab has 1 field of lenth say 1000 in which data stored is tab seprated.
    please find below my code, please check loop at t_intab
    FUNCTION Z_TEXT.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(I_EXPTABLE) TYPE  LVC_T_FCAT
    *"     VALUE(I_DELIMETER) TYPE  C DEFAULT 'T'
    *"  TABLES
    *"      T_INTAB
    *"      T_OUTTAB
    Data declarations
    DATA:
      dtab           TYPE REF TO data,
      newstr2        TYPE REF TO cl_abap_typedescr,
      tab_type1      TYPE REF TO cl_abap_tabledescr,
      lref_ditab     TYPE REF TO data,
      lref_new_line  TYPE REF TO data.
    Field-Symbols declarations
    FIELD-SYMBOLS:
    <fs_dyn_tab1> TYPE  ANY TABLE,
    <fs_dyn_wa>   TYPE ANY,
    <fs>          type any.
    Create dynamic table
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog           = i_exptable
        IMPORTING
          ep_table                  = lref_ditab
        EXCEPTIONS
          generate_subpool_dir_full = 1
          OTHERS                    = 2.
       IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Assign the dynamic table reference to a field-symbol
      ASSIGN lref_ditab->* TO <fs_dyn_tab1>.
    Create a structure similar to the dynamic table created
      CREATE DATA lref_new_line LIKE LINE OF <fs_dyn_tab1>.
      ASSIGN lref_new_line->* TO <fs_dyn_wa>.
    loop at t_intab.
    if I_DELIMETER = 'T'.
    split t_intab at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into .
    endif.
    endloop.
    ENDFUNCTION.
    thanks
    bobby

  • Split TempDB Data file into multiple files

    Hey , 
    I have been seeing TempDB contention in memory on our SQL server 2012 Enterprise Edition with SP2 and I need to split TempDB Data file into multiple files .
    Could someone please help me to verify the following information:
    1]
    We are on SQL server 2012 Enterprise Edition with service pack2 but as per SQL Server 2012 Enterprise Edition under CAL Licensing –We are limited to use 20 logical processors instead 40 logical processors. Our SQL is configured
    on NUMA nodes and with the limitation SQL uses only 2 NUMA nodes on live .There are 10 logical CPUs are evenly assigned to each NUMA nodes. Microsoft recommends that if SQL server configured on NUMA node and we have 2 NUMA nodes, then we may add two data files
    at a time. Please let me know should I add two TempDB data file at a time?
    2] We have TempDB Data and log files both on the same Drive of SQL server  .When I split TempDB into two Data files, I can get them on the same Drive .What your recommendation should I need to create TempDB Data files on the same drive or on separate
    disks?
    3] What would be the blackout plan for splitting the tempdb into multiple files? Please let me know if someone has a better back out plan ?
                1] Run script that create tempdb Database with a single file
    2] Reboot SQL service in order to apply change   
    Your help will be apprecited .
    Thanks ,
    Daizy

    Tom , I am seeing TempDB contention on Production server when there is a heavily load on sql server . We also experiencing the overall system slowness.Please look at Pagelatch wait statistics on our server ,Please advise .
    wait_type
    waiting_tasks_count
    wait_time_ms
    max_wait_time_ms
    signal_wait_time_ms
    PAGELATCH_UP
    2680948
    3609142
    10500
    508214
    PAGELATCH_SH
    1142213
    1338451
    8609
    324538
    PAGELATCH_NL
    0
    0
    0
    0
    PAGELATCH_KP
    0
    0
    0
    0
    PAGELATCH_EX
    44852435
    7798192
    9886
    6108374
    PAGELATCH_DT
    0
    0
    0
    0
    Thanks ,
    Daizy

Maybe you are looking for