Retrieve rows between timestamps

Hi,
I have a transaction table that have updates through out the day Now I need to retrieve rows that are updated between two timestamps.
I'm tryin to retrieve using s_timestamp between TS1 and TS2 but it says not valid month. Then I tried to_char(s_timestamp,'HH:MM:SS') between to_char(ts1,'HH:MM:SS') and to_char(ts2,'HH:MM:SS') it retuns no rows.
Now I tried
to_char(s_timestamp,'HH:MM:SS') between '10:10:20' and '12:12:30' Even then it retuned no rows. I'm sure there is data in there. Can anybody please suggest a solution.
Thanks

to_char(s_timestamp,'HH:MM:SS') between '10:10:20' and '12:12:30'The value '10:10:20' is a constant STRING and is no longer a time value (it may look like a time value, but to the DB it is just a string comparision at this point).
It just compares the to_char conversion of s_timestamp to be between the strings '10:10:20' and '12:12:30' (not between two time values).
SQL> create table test (s_timestamp date);
Table created.
SQL> INSERT INTO test VALUES (SYSDATE);
1 row created.
SQL> SELECT *
  2  FROM   test
  3  WHERE  s_timestamp BETWEEN
  4         to_date('10-oct-2004 04:00:00',
  5                 'dd-mon-yyyy hh24:mi:ss') AND
  6         to_date('10-oct-2004 05:00:00',
  7                 'dd-mon-yyyy hh24:mi:ss')
  8  /
S_TIMESTAMP
10-OCT-2004
1 row selected.
SQL>

Similar Messages

  • How to retrieve rows from .csv file

    Hi
    I need to retrieve rows from .csv file , anybody's kind support is greatly appreciated.
    Thanks in advance.
    Khiz_eng

    a .csv file is just a comma delimited text file. each row contains data separated by a comma. To read this information in, do as Hartmut suggested to your earlier post on this exact topic. "I would read that file with a FileReader / BufferedReader and parse each line with StringTokenizer. This would be quite the same like working through a result set." For more info on how to read text files, see any java book or browse through the i/o tutorial.
    Jamie

  • How to get each row between ranges

    Hi,
    How can i get the each row between range.
    e.g
    I have date range, 01012005 to 01012007.
    I want to get all month and year in internal table between this range.
    helpfull answers will be rewarded.
    Thanks,
    Message was edited by:
            Sal Khan

    data : begin of itab occurs 0,
             month(2),
             year(4),
            end of itab.
    data : lv_start type sy-datum,
             lv_end type sy-datum.
    lv_start = '20050101'.
    lv_end =  '20070101'.
    while lv_start le lv_end.
    itab-month = lv_start+4(2).
    itab-year = lv_start+0(4).
    append itab.
    lv_start4(2) = lv_start4(2) + 1.
    endwhile.

  • How to use between timestamp in where clause

    Hi All,
    i have a colum column2 of data type timestamp.now i wants to fatch record having between two date of column2.how to use between operator in where condition having column as timespamp'

    Hi,
    You can use a timestamp literal, or use a function that return a timestamp datatype, here is an example:
    (TIMESTAMP 'YYYY-MM-DD HH24:MI:SS.FF')
    select * from yourtable where column2 between TIMESTAMP '1997-01-31 09:26:50.12' and  systimestampHave a look to the documentation, for example http://download.oracle.com/docs/cd/B19306_01/server.102/b14225/ch4datetime.htm

  • Crystal Report stops retrieving rows against SAP BW query

    We're running Crystal Reports againist SAP BW and coming up a strange issue. We run the report and the BW query returns rows as normal. However, when the rowset reaches 50K (exactly) the report stops retrieving records. There is no error message - the report simply stops retrieving rows. We know there are additional rows that can be returned by the query. Anyone seen this before?

    Hi,
    what are the versions / patches used on the SAP Side and on the SAP BusinessObjects side ?
    Ingo

  • How to add blank rows between groups of duplicate rows?

    here is my setup
    create table #tmpA(rowID int identity(1,1), fName varchar(10), lName varchar(10))
    insert into #tmpA
    select 'a', 'b' union all
    select 'a', 'b' union all
    select 'c', 'd' union all
    select 'c', 'd' union all
    select 'e', 'f' union all
    select 'e', 'f' union all
    select 'g', 'h' union all
    select 'g', 'h'
    select distinct fName, lName
    into #tmpB
    From #tmpA
    select t1.* from #tmpA t1 Join #tmpB t2 on t1.fName = t2.fName and t1.lName = t2.lName
    --output
    rowID  fName  lName
    1             a         b
    2             a         b
    3             c         d
    4             c         d
    5             e         f
    6             e         f
    7             g         h
    8             g         h
    I want to add blank rows between rows 2 & 3 and between rows 4 & 5 and between rows 6 & 7 in the join query above.  Is there Tsql that can accomplish something like this to make the join query result look like the following output?
    rowID  fName  lName
    1            a          b
    2            a          b
    3            c          d
    4            c          d
    5            e          f
    6            e          f
    7            g          h
    8            g          h
    or if this is not possible I could go with an output like this:
    rowID  fName  lName
    1             a         b
    2             a         b
    3
    4             c         d
    5             c         d
    6
    7             e         f
    8             e         f
    9
    10           g         h
    11           g         h
    Rich P

    I came up with the following on my own.  I was just hoping there might be a fancier way to do this - like without looping -- and yes, I could/should do this in a presentation layer, but I just wanted to do this in Query Analyzer (or whatever they call
    it now -- SSMS ...) -- BTW, thanks CELKO for the suggestion about how to insert multiple rows using Values -- works great.
    If (object_id('tempdb..#tmpA') is not null) drop table #tmpA
    If (object_id('tempdb..#tmpC') is not null) drop table #tmpC
    create table #tmpA(rowID int identity(1,1), fName varchar(10), lName varchar(10))
    insert into #tmpA
    values
    ('a','b'),
    ('a','b'),
    ('c','d'),
    ('c','d'),
    ('e','f'),
    ('e','f'),
    ('g','h'),
    ('g','h')
    create table #tmpC(rrowID int Identity(1,1), rowID int, fName varchar(10), lName varchar(10))
    declare @i int, @s varchar(10), @t varchar(10), @u varchar(10), @v varchar(10)
    select @i = min(rowID) from #tmpA
    set @u = 'xx'
    While (@u != 'yy')
    Begin
       select @s = fName, @t = lName from #tmpA Where rowID = @i
       if exists(select 1 from #tmpA Where rowID = @i + 1)
          select @u = fname, @v = lName From #tmpA Where rowID = @i + 1
       else
          set @u = 'yy'
        if @s = @u And @t = @v
           begin  
             Insert Into #tmpC(rowID, fName, lName) Select * from #tmpA Where rowID = @i
             Insert Into #tmpC(rowID, fName, lName) Select * from #tmpA Where rowID = @i + 1
           end      
        else
           begin
              Insert Into #tmpC(rowID, fName, lName) Select null, '', ''  
           end
        set @i = @i + 1
    End
    select * from #tmpC
    --output from #tmpC
    rrowID  rowID  fName  lName
      1            1         a        b
      2            2         a        b
      3          NULL 
      4            3         c        d
      5            4         c        d
      6          NULL  
      7             5         e        f
      8             6         e        f
      9           NULL  
      10           7          g        h
      11           8          g        h
      12         NULL  
    Rich P

  • Retrieving rows in reverse order

    Hi all,
    I wish to retrieve row data in reverse order. Iam not retrieving the data in any particular sorting order, i just want a simple reversal of rows returned for eg.
    say initially data returned is
    Name Age
    abc 20
    bbb 25
    ccc 19
    ddd 22
    I want it as
    Name Age
    ddd 22
    ccc 19
    bbb 25
    abc 20

    The order of rows isn't random, but it is arbitrary. While it is probable that "select * from emp" will return rows in the same order today as it did yesterday, Oracle is certainly under no obligation to do so. If there are any changes to the table-- new rows, deleted rows, modified rows, table reorganization, etc.-- if there are changes to the statistics for the tables, or if there are changes to the database, the order rows will be returned in will change. Changes to the Oracle version might change the order rows are returned in as well.
    While it is unlikely to happen in practice, it would be prefectly legal for Oracle to return rows in exactly the same order for both of Laurent's queries. In practice, they are reasonably likely to return rows in the opposite order most of the time.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • ROWS BETWEEN 12 PRECEDING AND CURRENT ROW

    I have a report with the last 12 months and for each month, I have to show the sales sum of the last 12 months. For example, for 01/2001, I have to show the sales sum from 01/2000 to 12/2000.
    I have tried this:
    SUM(sales)
    OVER (PARTITION BY product, channel
    ORDER BY month ASC
    ROWS BETWEEN 12 PRECEDING AND CURRENT ROW)
    The problem is: this calculation only considers the data that are in the report.
    For example, if my report shows the data from jan/2001 to dec/2001, then for the first month the calculation result only returns the result of jan/2001, for feb/2001, the result is feb/2001 + jan/2001.
    How can I include the data of the last year in my calculation???

    Hi,
    I couldn't solve my problem using Discoverer Plus functions yet...
    I used this function to return the amount sold last year:
    SUM("Amount Sold SUM 1") OVER(PARTITION BY Products.Prod Name ORDER BY TO_DATE(Times."Calendar Year",'YYYY') RANGE BETWEEN INTERVAL '1' YEAR PRECEDING AND INTERVAL '1' YEAR PRECEDING )
    The result was: it worked perfectly well when I had no condition; so it showed three months (1998, 1999, 2000) and two data points (Amount Sold, Amount Sold Last Year). The "Amount Sold Last Year" was null for 1998, as there aren't data for 1997.
    Then I created a condition to filter the year (Times."Calendar Year" = 1999), because I must show only one year in my report. Then I got the "Amount Sold" with the correct result and the "Amount Sold Last Year" with null values. As I do have data for 1998, the result didn't return the result I expected.
    Am I doing something wrong??

  • Is it possible to insert row with timestamp field without to TO_TIMESTAMP

    hello
    is it possible to insert row with timestamp column without using to_timestamp unction
    somthing like insert into app.master values (3,333, 'inser tmstmp', 6.7, '2010-11-10 15:14', 'f','9','2010-12-22')

    784633 wrote:
    hello
    is it possible to insert row with timestamp column without using to_timestamp unction
    somthing like insert into app.master values (3,333, 'inser tmstmp', 6.7, '2010-11-10 15:14', 'f','9','2010-12-22')If you don't like the answers in your previous thread (Re: how can i set timestamp format don't expect to get different answers just because you start a new thread.

  • Rows between 101 and 150

    Hi,
    I want the rows between 101 and 150 for all values
    Select * from MQ where rownum between 101 and 150
    In the above is query is not working.
    and I tried this query too ,It is also not working
    Select * from MQ where (select rownum from MQ were rownum between 101 and 150)
    Here I am getting only Rownum.
    Please help

    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/pseudocolumns009.htm#SQLRF00255
    Select  *  from
        (select   rownum   my_rownum
                 , MQ.* 
           from MQ
    where my_rownum between 101 and 150

  • How to retrieve day between two dates?

    Hi all,
    Hope doing well,
    sir i am retrieving day between two dates in sql server like this.
    select datediff(day,'2012-10-03 00:00:00.000','2012-10-05 00:00:00.000')
    and getting result that is: 2
    but how this type of query i'll use in oracle?
    thanks,

    Just do minus
    diff := date_variable2-date_variable1;The difference sill be in days.
    If you want just the differences in days (Neglecting time part)
    diff := trunc(date2)-trunc(date1);

  • Retrieve rows in order as they are feeded

    Hello all
    My problem is that when i retrieve records from a table the rows are in order in which they are feeded but after joining the table with others the retrieve sequence is changed. I want to get data in the same order in which they are feeded even after joining. further more ordery by clause is also not fruitful

    very easy : add a timestamp !
    SQL> create table t99(n number);
    Table created.
    SQL> alter table t99 add (t timestamp default current_timestamp);
    Table altered.
    SQL> insert into t99(n) values (1);
    1 row created.
    SQL> insert into t99(n) values (2);
    1 row created.
    SQL> select n from t99 order by t;
             N
             1
             2if you cannot do that, than you cannot order by!

  • Difference between timestamp oracle datatype as unix timestamp

    Hi
    We are having a column in our table as create_ts which is the time, the row is updated. We are in need to get this time in Pro*c as unix timestamp type to find out the oldest row from a set of rows.
    I found that the following query works when I convert to date and find out the difference.
    select TO_NUMBER((TO_DATE (TO_CHAR (CREATE_TS, 'YYYY-MON-DD HH24:MI:SS'),'YYYY-MON-DD HH24:MI:SS') - to_date('01.01.1970 00:00:00','dd.mm.yyyy HH24:mi:ss')) * 24 * 60 * 60 - TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone),1,3))*3600 ,9999999999) as timestamp from customer;
    However when I keep it as timestamp type I'm getting some error
    select TO_NUMBER((CREATE_TS - to_timestamp('01.01.1970 00:00:00','dd.mm.yyyy HH24:mi:ss'))* 24 * 60 * 60 *1000 - TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone),1,3))*3600000 ,9999999999999) as timeints from customer;
    ERROR
    ORA-30081: invalid data type for datetime/interval arithmetic
    30081. 00000 - "invalid data type for datetime/interval arithmetic"
    FYI: since if I convert to date type, we're losing the microseconds, we had to find the difference using the timestamp type.
    thanks

    When you take a difference between two timestamps, You dont get a number(like substracting dates). You get a string that has number of days,hours,minutes and seconds.
    You can break the string though,
    SQL> SELECT SUBSTR(today,1,30) today,
      2         SUBSTR(tomorrow,1,30) tomorrow,
      3         SUBSTR((tomorrow-today), INSTR((tomorrow-today),' ')+7,2) "SS",
      4         SUBSTR((tomorrow-today), INSTR((tomorrow-today),' ')+4,2) "MI",
      5         SUBSTR((tomorrow-today), INSTR((tomorrow-today),' ')+1,2) "HH",
      6         TRUNC(TO_NUMBER(SUBSTR((tomorrow-today),1, INSTR(tomorrow-today,' ')))) "Days"
      7    FROM (SELECT TO_TIMESTAMP(SYSDATE) today,TO_TIMESTAMP(SYSDATE+1) tomorrow FROM dual);
    TODAY                          TOMORROW                       SS MI HH       Days
    10-MAR-11 12.00.00 AM          11-MAR-11 12.00.00 AM          00 00 00          1
    SQL>
    SQL> G.

  • How to retrieve row data from a  table

    Hey,
    Have a table with data and each row has one column which is a button. How do I retrieve the corresponding data of the row in which the button was clicked. Meaning what do I need to do differently in the table and what type of javascript on an onclick event etc would I need to get the data. If there is a better or simpler approach im open to any suggestions.
    Thanks in advance for your assistance
    e.g.
    <table>
    <tr>
    <td>column1 data</td><td>column 2 data</td><<input type="button" value="select" onclick="?????"/>
    </tr>
    </table>

    In the onclick event submit the jsp with query string.
    <onclick="process.do?rowId=<%=column1 data%>">
    have column 1 data as a unique identifier. Using request.getParameter get the column1 data value and query the db again to fetch the whole row data. I guess, it will work.

  • How to retrieve rows in view object and display on UI

    Hi All,
    I am new to ADF. i am using jdeveloper11.1.1.5.0 . Here is my scenario.
    In my AM i have a view object say EmployeeVo. on empVo i am performing setRangeStart and setRangeSize.
    empVo .setRangeStart(2);
    empVo .setRangeSize(2);
    Rows[] rows=empVo .getAllRowsInRange();
    so from the above statement will get two rows from the empVo object. Now i have to display these rows in UI in the form of af:table.
    Can anyone suggest how to acheive this.
    Thanks in advance.

    <af:table value="#{Bean.listValue}" var="row" />
    //refer rows like
    <af:column>
    <af:inputText value="#{row.description}" />
    </af:column>
    List listValue = new ArrayList();
    //getter setter of listValue
    //bean constructor
    retrieve the rows from the AM methodthe above step is very crude hope you understand the steps

Maybe you are looking for

  • Adding paragraphs to the spry photoalbum

    I used this tutorial to build a phto album: http://www.adobe.com/devnet/dreamweaver/articles/spry_photo_album.html So I don't know if what I'm asking for is possible, but I figured I may  as well ask. I have a site for a movie that uses this gallery

  • SAP ECC 6.0 and EHP5 Installation with DIMP functionatilty

    Hi Frineds, We are installaing ECC6.0 and EHP5 fresh installation and looking for DIMP functionality too active in the system. If we do only installation only  Central Application Usage type then we can directly install EHP5 system  (Central Applicat

  • MAC OS 10.5.7 FireWall & Java Socket programing

    Hi everyone, I am fighting for few days with a simple problem in vain. I am programming a simple java client-server application based on TCP sockets but I do not manage to open any socket at all due to a "connection refused" problem: In the previous

  • IPhoto 11 keeps crashing immediately after opening. Is there a fix?

    It's happened about 10 straight times now. I have installed the most recent update. Running Lion. Has this happened to anyone else and does anyone know how to fix it? Thanks.

  • Function with string input value

    hi can someone please tell me why this function does not return a value: FUNCTION Get_Rate(p_rate_value IN VARCHAR2) RETURN SCR_RATES.rate_value%TYPE IS CURSOR get_rates IS SELECT rate_value FROM SCR_RATES WHERE rate_type = to_char(p_rate_value); get