Dates in concatinations

I am running a query on a table with a primary key of column a, column b, and a date.
When I run a query concatinating all the columns of the key and counting the records with the same primary key combo.
For instance:
Select columnA||columnB||key_date, count(*)
from table
group by columnA||columnB||keydate
having count(*) > 1;
I get several rows with a count greater than 1.
When I look at the individual records you can see the time
stamp on the dates vary. But since I didn't do a trunc on the date; I didn't expect them to be grouped together. When you concatenate; do you lose the time stamp on the date?

If you rely on implicit conversions - which is what you are doing here - the date will get converted to a string using whatever default nls_date_format you have set, which is usually DD-MON-YY.
The key is to never rely on these implicit conversions - always convert dates to strings, etc. yourself.
sql>alter session set nls_date_format = 'DD-MON-YYYY';
Session altered.
sql>select 'a' || 'b' || sysdate from dual;
'A'||'B'||SYS
ab20-FEB-2003  -- see how the time gets dropped
1 row selected.
sql>select 'a' || 'b' || to_char(sysdate, 'yyyymmddhhmiss') from dual;
'A'||'B'||TO_CHA
ab20030220114814
1 row selected.

Similar Messages

  • Concatination of Two dates in customer exit Variable

    HI Expert ,
    I am writting customer Exit Variable to get Records from user entered Dates .
    Eg. In Variable Screen of Bex report i have 2 Variable LYDate & TY Date both of them are As "Mutiple Single Value" & "Mendetory".
    If we give LYDATE and TYDATE Date range as,
    LYDate - 01/2013 - 06/2013
    TYDate - 01/2014 - 12/2014
    So I need ABAP Code which will get Value Range from 01/2013 from LYDATE and 12/2014 From TY DATE . So Query will Get data for 01/2013 TO 12/2014 (2 Years Data).
    ZCALYEAR (Cusomer Exit)  = LYDATE (01/2013)  TO TY DATE(12/2104).
    Please provide step by step ABAP Code to Achiev above issue. Points for Sure...
    Thanks,
    GB

    Hi,
    Some code like this will solve your issue:
    CASE I_VNAM.
       WHEN 'NEWVARIABLE'.
       IF I_STEP = 2.
          READ TABLE I_T_VAR_RANGE INTO LOC_VAR_RANGE WITH KEY VNAM = 'LYDate'.
          If sy-subrc =0.
              CONCATENATE LOC_VAR_RANGE-LOW(4) INTO L_S_RANGE-LOW.
              READ TABLE I_T_VAR_RANGE INTO LOC_VAR_RANGE WITH KEY VNAM = 'TYDate'.
              If sy-subrc =0.
                   CONCATENATE LOC_VAR_RANGE-HIGH(4) INTO L_S_RANGE-HIGH.
                   L_S_RANGE-SIGN = 'I'.
                   L_S_RANGE-OPT = 'EQ'.
              APPEND L_S_RANGE TO E_T_RANGE.
            endif.
          endif.
        endif.
    endcase.
    Regards
    Yasemin...
    Just realized that you need the year. Message was edited by: Yasemin ULUTURK

  • Date concatination to export file name on windows / Novell

    Hi everybody,
    I need utility which can add date at end of export file. How its possible in DOS/Windows/NT/Novell.
    eg: exprod.dmp --- exprod07122002.dmp
    Thanks

    If you're invoking export with a shell script you could do something like:
    exp file=exp%date%.dmp <other options>
    If you want to format the date you need to do something ugly like:
    setlocal
    for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
    set DayOfWeek=%%i
    set Month=%%j
    set Day=%%k
    set Year=%%l
    exp file=exp%Day%%Month%%Year%.dmp <other options>
    endlocal
    -Antti

  • Concatinating Date for a file name

    i have the following shell script ..when i execute it manually line by line iam getting Invalid command
    mv js010d02.txt js010d02_`date +%y%m%d`.txt
    i want my file js010d02.txt to be renamed like this js010d02_081117.txt
    can anyone help me ..
    Thanks in advance,
    Data boy

    Please provide as much information as possible.
    The most obvious one is the execution and the errormessage on the system.
    Furthermore, o/s version and architecture would be handy.
    The quality of the answer depends on the quality of the question...

  • Get Date +time from Oracle

    hi ,
    i saw that i can take date and time in seperate from the ResultSet .
    how can i take the Time part as well from the date in the DB .
    is there a way to create a new Date with the Time from the DB concatinated to it ?
    doing as follows is apparently wrong ...
    Date taskStartDate = rs.getDate("start_assign");
                   Time taskStartTime = rs.getTime("start_assign");
                   long tt= taskStartTime.getTime();
                   Date taskStartDate = new Date(taskStartDatetmp.getTime()+tt);please advise .

    You could convertjava.sql.Date sqlDate = resultSet.getDate("foo");
    java.util.Date javaDate = new
    java.util.Date(sqlDate.getTime());
    This only works if the driver is ignorant enough to pass through millisecond values containing hours/minutes/seconds to the sql.Date, thus violating the contract of sql.Date.

  • How to make use of adjacent data elements within the same buffer

    Hi,
             Does anyone know how to make use of adjacent data elements within the same buffer? To make my question clearly, I would like to give you an example. In my application, I set "sample to read" as 10 which means at each loop 10 data samples will be taken into a buffer. Now, what I would like to do is to do some calculations on adjacent data samples in same buffer. I tried to use "shift register" for this, but it seemed to me that it only can deal with the calculation between data from adjacent loops. In other words, it skips 9 data elements and take the 10th one for the calculation.
             Here I also attach my VI showing what I did.
        Thank you very much in advance,
                            Suksun
    Attachments:
    wheel_encoder_1.vi ‏98 KB

    Hi Suksun,
          I hope you'll forgive me for distilling your code - mainly to understand it better.  I tried to duplicate your logic exactly - which required reversing the "derivatives"-array before concatination with the current samples array.  As in your code, the last velocity is being paired with the first position.  If first velocity is really supposed to be paired with first position, just remove the "Reverse 1D Array" node.
    cheers
    Message Edited by Dynamik on 01-07-2006 03:17 AM
    Message Edited by Dynamik on 01-07-2006 03:19 AM
    When they give imbeciles handicap-parking, I won't have so far to walk!
    Attachments:
    encoder2.GIF ‏14 KB
    encoder2.vi ‏102 KB

  • Converting a text string to a date in Discoverer

    I've got a problem with a discoverer report which is that an item is pointing to a field in the Oracle table which is named as a segment4. This appears to be a generic field which stores any type of data, as it is based on the result of a flex-field in the application, so you could have dates, text, numbers etc. The problem is that the dates are stored in the table back to front i.e. 2004/10/19 00:00:00 and I need to be able to convert the date values so they are in the format DD-MON-YYYY as is this is the format that we use for all our reporting. When I try to apply any kind of date function it doesn't seem to work because it's a text field. I've used SUBSTR to get the first 10 characters and then used it again to split into day, month, year and then concatinated the values into one field in the correct order. This works to a certain degree but still doesn't recognise the value as being a date because because it doesn't sort them in order i.e. 20-06-2007 would appear before 30-06-2005. I'm not sure whether Discoverer could fix the problem or whether it may something the DBA may have to apply to the table. Does anyone have any suggestions to how I can get around this problem?
    Thanks.
    Joanne Hulme, Bolton Council.

    Hi,
    You can use TO_DATE(segment4, 'YYYY/MM/DD HH24:MI:SS') in a calculation to convert the segment to a oracle date type.
    You can then format the date in anyway you need.
    Rod West

  • How to save data in file by puting the data in different colomns ?

    I am compiling a program by using Labview, and I use the 5 loops. For every loop, I get 10 data. I want to save all data in a file. But I don't want put them in one colomn, and just want to put the data getting from one loop in a colomn, and thus in my file, there should be 5 colomns. i.e. for every data for one loop should be in one colomn. How can I do that ? Thanks.

    If you are going to save the data as text, e.g. a tab delimited spreadsheet, then you decide what data goes where by formatting the data; concatinating the different cell values with tab constants (to separate rows) and carriage return line feed to separate rows...
    See attached example.
    If you want to write the data as a binary file create a 2D array with the correct number of columns and rows and use the replace array element function to insert the values where they belong...then save the array.
    MTO
    Attachments:
    format_2_text.gif ‏15 KB

  • Timestamp field in Generic Data sourcce.

    Hi All,
    i have created a generic datasource using tables vbrp,vbrk.mara,marc,knvv.. to get the sales data for planning.Here i have document created date and time.So i'm concatinating these 2 date and time fields into timestamp which is of format yyyymmddhhmmss.Finally i'm using this timestamp to extract data .
    So is it the right way to pull the data using timestamp and what is the timezone i need to specify as the servers are in india only.
    or any other way to proceed.
    Thanks
    Rao.

    Hi VS,
    The following are the delta specific fields that can be  used while creating a generic data source.
    1. Time stamp - The field is a DEC15 field which always contains the time stamp of the last change to a record in the local time format.
    2. Calendar day - The field is a DATS8 field which always contains the day of the last change.
    3. Numerical pointer - The field contains another numerical pointer that appears with each new record
    Also the following are some useful links about delta setting in generic datasources.
    |http://help.sap.com/saphelp_nw04s/helpdata/en/37/4f3ca8b672a34082ab3085d3c22145/frameset.htm]
    Creation of Generic DS:[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/84bf4d68-0601-0010-13b5-b062adbb3e33]

  • Create index in solr & cf9 from query data

    Hey guys,
       Does anyone have a working example of cfindex where input data comes from a query and where you can search said index for a given value in a specified field.
        I create an index as below.
        <cfindex action="update" query="v_test" collection="lib_30" type="custom"
                 key="sequenceId" title="Lib 30 index" body="#v_test.columnList#" category="#v_test.columnList#"
                 status="report">
        This creats an index but my fields tag in index are empty, and all the data in each column is concatinated together to create one long string.
         I have googled, and tried to make heads and tails of the live doc, but I haven't been successful
         Any one, please help
    Jay

    I can't see any evidence that CF supports individual search fields with Solr.  The <cfindex> implementation for Solr seems to just replicate what it did for Verity: bung all the data from the various columns specified in the BODY attribute into one long string.
    I hasten to add that my comment is not based on code-based investigation, but just my reading of the docs coupled with your findings.  And tangential experience with CF's Solr integration implementation which I have found to be a bit... basic.
    Adam

  • Output from Tlist concatinated???

    Hi,
    i have this data in a table
    sample format is below
    ID   Name
    1    A
    2    B
    3    C
    4    D
    5    E
    .and so on
    I am using the following code to populate the Name column in my non-db Tlist in a Form
    DECLARE
    RG_NAME_1  VARCHAR2(40) := 'my_data';
    RG_ID_1    RecordGroup;
    ERROR_1    NUMBER;
    BEGIN
        RG_ID_1 := FIND_GROUP(RG_NAME_1);
        IF NOT ID_NULL(RG_ID_1)
    THEN
        DELETE_GROUP(RG_ID_1);
    END IF;
        IF ID_NULL(RG_ID_1)
    THEN
    RG_ID_1 := CREATE_GROUP_FROM_QUERY(RG_NAME_1, 'SELECT NAME,TO_CHAR(ID)
                                 FROM T ORDER BY 1');
    END IF;
    ERROR_1 := POPULATE_GROUP(RG_ID_1);
       IF ERROR_1 = 0
    THEN
       POPULATE_LIST('block.tlist, RG_ID_1);
    END IF;
    EXCEPTION
    WHEN
       NO_DATA_FOUND
    THEN
       NULL;
    END;Well all this is working very fine
    my Tlist is populated with 'names' at run time
    the problem is that i want to achive 2 things
    1. To show the respective clicked Name(s) in a non-database text item and the clicked name is deleted from the tlist. If the user clicks more than one name then the Names in the text item should be concatinated with a comma and a space
    For example, if the user clicks 'A' then 'A' should be deleted from tlist and should come in the non-db text item. If the user clicks another element then that element should also be deleted from Tlist and come in the text item as
    A, B
    and so on..
    in the second requirement I want only the ID behind the clicked name should come in another text item and the clicked Name is deleted from the tlist.
    Incase of more than one selection the ID's should come concatinated with a comma and a space in the Text item just as explained above..
    For exmaple: user clicks 'A', then 'A' should be deleted from the tlist and its ID should come in the text item. On further click the same procedure follow and the next ID comes after the first ID as 1,2
    and so on
    I would be extremly grateful if somone tells me with example code how to achieved this
    regards,

    assuming that you have two items.
    list item - blk_ctl.list
    text_item - blk_ctl.text
    add the below code in the WHEN-LIST-CHANGED trigger of the list item.
    begin
      --pad the values to a text item
         if :blk_ctl.text is not null then
              :blk_ctl.text := :blk_ctl.text||','||:blk_ctl.list;
         else     
              :blk_ctl.text := :blk_ctl.list;
         end if;     
      --loop through the list to find the selected element
      --and delete it
         for i in 1..get_list_element_count('blk_ctl.list')
         loop
                   if get_list_element_value('blk_ctl.list', i) =  :blk_ctl.list then
                        delete_list_element('blk_ctl.list', i);
                   end if;
         end loop;
    end;

  • Clear address bar of data

    Hi all,
    I was wondering if anyone knows how to clear the address bar
    of a browser after you are taken to a webpage and returned to the
    original page. For example I have a list of potential clients on a
    web page with a link to a detail page, I click the link go to the
    detail page and make an edit. I have the redirect back to the
    orginal page and now if I was to click another clients I get an
    error because in the address bar I still have data from the
    previous detail page. It looks like
    "deleteaccesstomofsystem2.asp?ID=11&ID=10" As you can see it
    keeps concatinating the ID= whatever you click next. Problem is you
    get an error.
    Thanks,
    Lenny

    On Tue, 9 Oct 2007 11:42:45 +0000 (UTC), "Lenny@ford"
    <[email protected]> wrote:
    >aken to a webpage and returned to the original page. For
    example
    >I have a list of
    DW inserts this code after the update procedure:
    $insertGoTo = "YOUR_PAGE.php";
    if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
    header(sprintf("Location: %s", $insertGoTo));
    Where your YOUR_PAGE is replaced with whatever your master
    page is.
    Simply delete the if{ } segment to leave:
    $insertGoTo = "YOUR_PAGE.php";
    header(sprintf("Location: %s", $insertGoTo));
    Steve Fleischer
    steve at flyingtigerwebdesign dot com
    Hong Kong

  • Reseting Table Data Model

    i have created JTREE consisting of all the table name and columns of tables present in Database .Now upon clicking a Specific table i want to display the Structure of database table on the right side of Split pane .
    Problem i am facing , i am not able to reset thetJTable data model.when i click second time to get the table structure , the Jtable is appearing under the previous one,...concatinating with the result of previous selection .
    here is my code
    ???public class DatabaseTree implements TreeSelectionListener
         static JTree tree;
         static DefaultMutableTreeNode list,col,top;
         static JTable table;
         static  DefaultTableModel default_table;
          static Vector column = new Vector();
         static Vector data = new Vector();
          static String url = "jdbc:oracle:thin:@192.168.0.149:1521:xe";
          static String user = "compiere";
          static String password = "compiere";
          static Connection conn;
          static Statement stmt,stmt2 ;
          static Statement stmt1 ;
          static JSplitPane splitPane;
         static JScrollPane treescroll,jtablescroll;
         DatabaseTree()
           top =new DefaultMutableTreeNode("Compiere Database Tables");
          tree = new JTree(top);
          tree.setRootVisible(true);
          table = new JTable();
    treescroll = new JScrollPane(tree);
    jtablescroll = new JScrollPane(table,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,treescroll, jtablescroll);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(200);
    //Provide minimum sizes for the two components in the split pane.
    Dimension minimumSize = new Dimension(100, 50);
    treescroll.setMinimumSize(minimumSize);
    jtablescroll.setMinimumSize(minimumSize);
    ////Provide a preferred size for the split pane.
    splitPane.setPreferredSize(new Dimension(400, 200));
    tree.addTreeSelectionListener(this);
    try
       Class.forName("oracle.jdbc.driver.OracleDriver");
       conn = DriverManager.getConnection(url,user, password);
       stmt = conn.createStatement();
       stmt1 = conn.createStatement();
         String sql =("select table_name from user_tables");     
         ResultSet rs=stmt.executeQuery(sql);
         ResultSet rs1;
          while(rs.next())
         list = new DefaultMutableTreeNode(rs.getString("TABLE_NAME"));
        top.add(list);
         rs1=stmt1.executeQuery("Select column_name from user_tab_cols where table_name ='"+ rs.getString("TABLE_NAME")+"'");
         while (rs1.next())
              col= new DefaultMutableTreeNode(rs1.getString("column_name"));
              list.add(col);
        catch(Exception e1)
         System.out.println("errors "+ e1);
      public static void main(String[] args)
         JFrame  frame = new JFrame("Database Tree Structure");
       DatabaseTree dd=new DatabaseTree();
       frame.getContentPane().add(dd.getSplitPane());
       frame.setSize(450,450);
       frame.setVisible(true);
    public JSplitPane getSplitPane() {
            return splitPane;
    public void valueChanged(TreeSelectionEvent e) {
         // TODO Auto-generated method stub
         onSelectAction(e);
    private void onSelectAction(TreeSelectionEvent e) {
         // TODO Auto-generated method stub
         DefaultMutableTreeNode node = (DefaultMutableTreeNode)
        tree.getLastSelectedPathComponent();
    /* if nothing is selected */
    if (node == null) return;
    System.out.println();
    /* retrieve the node that was selected */
    String nodeInfo = (String) node.getUserObject();
    System.out.println(nodeInfo);
    /* React to the node selection. */
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    String url = "jdbc:oracle:thin:@192.168.0.149:1521:xe";
    String user = "compiere";
    String password = "compiere";
    conn = DriverManager.getConnection(url,user, password);
    Statement stmt = conn.createStatement();
    //String sql="desc '"+nodeInfo+"'";
    String sql=("select column_name,data_type,nullable,data_length from  user_tab_cols where table_name='"+ nodeInfo+"'");
    //System.out.println("23");
    ResultSet rs = stmt.executeQuery(sql);
    ResultSetMetaData md = rs.getMetaData();
       int columns = md.getColumnCount();
        System.out.println(columns);
        for (int i = 1; i <= columns; i++)
            column.addElement( md.getColumnName(i) );
        // System.out.println(column);
         while (rs.next())
            Vector row = new Vector(columns);
            for (int i = 1; i <= columns; i++)
                row.addElement( rs.getObject(i) );
            System.out.println(row);
            data.addElement( row );
              rs.close();
              stmt.close();
    catch(Exception e1)
        System.out.println( e1 );
    default_table=new DefaultTableModel(data,column);
    table.setModel(default_table);
    }

    [Vector.html#clear()|http://java.sun.com/javase/6/docs/api/java/util/Vector.html#clear()]
    private void onSelectAction(TreeSelectionEvent e) {
        data.clear();
    //...

  • Concatenating Date.

    Hi Jayaprasath, First concatenate date and timestamp with a space in between if both are of string datatype from source using the below.      v_concat_field=date_field|| ' ' || timestamp_field  Note: datatype of v_concat_field should be string If any of the date or timestamp field is of numberis datatype, then use to_char to convert into string before concatination like below      v_concat_field=to_char(date_field)|| ' ' || to_char(timestamp_field) Now in the output port with datetime datatype use the below logic.      o_concat_field=TO_DATE(v_concat_field,'YYYYMMDD HH24MI') Note: datatype of o_concat_field should be date Please let me know if you find any issues with the above approach. Thanks,Deeshan.  

    Dear All, As per my requirement, i'm getting date and timestamp seperatly, Date as 'yyyymmdd' and time as decimal of 4 (HH24MI). I need to load the both in a single date/Time Column as 'yyyymmdd HH24MI'. please help in solving the issue. ThanksJayaprasath S

  • Reports Data Plotting Problems

    I am concatinating several files from data collected at 1hz.  There is often large time gaps between each file.  How can I have the plots not connect the lines between each file set.  It often makes the data look like it flat lined.

    Hi bm2cox,
    The short answer is to insert a row of NoValues between concatenations.  I happen to be retooling my multiple file concatenating VBScripts which are posted on the web, and it occurred to me to add this as a parametrizable feature.  Could you send over an example set of data files?  If my VBScript works on them, I'll send it to you sometime today.
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments
    [email protected]

Maybe you are looking for

  • IPod mini not found

    Hi, whenever I connect my ipod to the computer I get this message: "The iPod "my iPod" cannot be synced because there is not enough free space to hold all of the items in the iTunes library (4.27 GB required, 3.75 GB available). Would you like iTunes

  • How do i stop ITC2 files appearing in my music library?

    I noticed that several ITC2 files appear in my music library where I save all of my music. When I play some music in my itunes there are whole bunch of ITC2 files in my music library. What do i have to do to stop them appearing in my music folder.

  • ITunes Store movie selection...(USA)

    Does iTunes Store plan on hosting any non-Disney movies? I just read about downloading videos and it specifically stated that all iTunes Store videos were from some sort of Disney company.

  • Whats better for college/grad school- ipad 3 with keyboard or mac book air? 11 inch

    whats better for college/grad school- ipad 3 with keyboard or mac book air? 11 inch

  • Ios7 beta stuck

    i have the ios 7 beta 5 and it won't let me download the full version. i tried downgarding but nothing works