Query between hours

Sorry for this newbie issue, but I´m having some problems here ...
I´ve made this query :
SQL> select to_date('7:00:00','HH24:MI:SS') from dual;
TO_DATE('
01-NOV-05
and it shows only the date ... but I don´t need the date , I need the HOUR, because I would like to make a query like this
select * from my_table where
connectedtime between to_date("7:00:00",'HH24:MI:SS') and
to_date("14:30:00",'HH24:MI:SS')
connectedtime is a DATE column
I need only the results between 7 AM and 2:30 PM
Any tips for this ?

Don't panic! That's just how SQL*Plus displays datetimes. It's quite easy to change...
SQL> SELECT sysdate FROM dual
  2  /
SYSDATE
08-NOV-05
SQL> ALTER SESSION SET NLS_DATE_FORMAT='HH24:MI:SS'
  2  /
Session altered.
SQL> SELECT sysdate FROM dual
  2  /
SYSDATE
12:26:38
SQL>One way of checking for time is to use the SSSSS format mask which calculates seconds since midnight...
SQL> r
  1  SELECT sysdate FROM dual
  2* WHERE to_number(to_char(sysdate, 'SSSSS')) BETWEEN 27000 AND 52200
SYSDATE
12:32:09
SQL> Cheers, APC

Similar Messages

  • Error while copy query between infocubes

    I was trying to copy a query between infocubes and ended with error message.
    Query copied from Infocube A to Infocube B. Infocube B has an additional dimension with 2 char's when compared to infocube A.
    Using transaction RSZC, I tried to copy the query, but ended up with following error..
    1.Program error in class COPY_QRY_TO_CUBE method : UNCAUGHT_EXCEPTION
    2.An exception with the type CX_SY_OPEN_SQL_DB occurred, but was neither handled locally, nor declared in a RAISING clause
    3.The system tried to insert a data record, even though a data record with the same primary key already exists
    I also tried using function module RSZ_I_COPY_QRY_TO_CUBE, which was of no help. I get the following message with the function module...
    1. Program error in class RS_TESTFRAME_CALL method : UNCAUGHT_EXCEPTION
    2. An exception with the type CX_SY_OPEN_SQL_DB occurred, but was neither handled locally, nor declared in a RAISING clause
    3. The system tried to insert a data record, even though a data record with the same primary key already exists
    I have also tried a solution in BW expert by using debugging mode of the above function module, again this was of no help..
    I am BI 7.0 SP09...
    Any ideas, Please....
    Thanks,
    RR
    Message was edited by:
            Ray R

    Hello,
    Are you trying to copy Business Content delivered Queries?
    I had also got this error when copying over all queries from one cube to another. Reason for this message was plain simple - I did not realise that the sender Cube had Business Content Query which we cannot copy over using RSZC as system tries to create another query with suffix as 0****_1. We cannot create query in SAP user namespace. Error message is different then the reason behind it.
    Thanks
    Ravi

  • Creating SELECT query between 3 tables

    Hi there,
    Im trying to create a SELECT query between 3 tables and it is driving me round the bend.
    I have 3 tables connected together which are:
    MODUL
    modulid
    modulname
    modulevel
    STUDENT
    studentid
    surname
    inits
    s e x
    phone
    email
    logon
    STUDREGOCCUR
    modulid
    acyear
    semester
    occletter
    studentid
    result
    I want to select the fields surname, inits, studentid from the STUDENT table, modulname from the MODUL table and result from my STUDREGOCCUR table that is NOT NULL.
    I have tried SELECT STUDENT.STUDENTID, STUDENT.INITS, STUDENT.SURNAME, MODUL.MODULNAME, STUDREGOCCUR.RESULT WHERE STUDREGOCCUR.RESULT IS NOT NULL;
    I have also tried many other ways and done research hwich hasnt really helped me unfortunately.
    Im quite new to SELECT queries and im not sure where im going wrong, i would greatly appreciate if someone could help me solve my problem.
    Thanks for the help :)
    Edited by: user633643 on 06-Dec-2008 08:09

    If you want data from multiple tables you would need to perform a join. The general form would be:
    select t1.cola, t2.col2, t3.col.x
    from table_a a, table_b b, table_c c
    where a.key = b.key
    and b.key = c.key
    or perhaps c relates back directly to a so it is a.key = c.key where key can be any column whose value is equilivent in what it represents to the value it is being compared to, that is, student_number = student_number or the columns regardless of name are both building numbers, room numbers, etc ....
    This is not your exact solution but it should help.
    HTH -- Mark D Powell --

  • Select Query Between two dates...

    Hi Guru's,
    I need a Select Query between two dates, also if the record not found for any in between date then it should return NULL or 0 ...
    for Example
    1. I am having two records in DB for date 2-10-2008 & 4-10-2008
    2. Now suppose I have given Query for date between 1-10-2008 to 5-10-2008
    Then it should return me 5 records with valid values for 2 & 4 and NULL for other 1,3,5
    Thanks.

    Try like this:
    with
      t as
          select date '2008-10-02' as dt, 'Record #1 (in DB)' as str from dual union all
          select date '2008-10-04' as dt, 'Record #2 (in DB)' as str from dual
    select v.dt, t.str
      from (
             select date '2008-10-01' + level - 1 as dt
               from dual
             connect by level <= (date '2008-10-05' - date '2008-10-01') + 1
           ) v
      left join t
        on v.dt = t.dt
    order by 1

  • Query between different infoproviders

    How to copy query between different infoproviders?

    Hi,
    It can be done throught he transaction RSZC
    1)     Run the Code RSZC and Input the Source and Target infoprovider name.Execute it.
    2)     Next screen you will get the option of which query to copy, select the query.
    3)     Go to next screen and change the name of the query that is in the destination. (If you want).
    4)     Next screen, Message is displayed if success or failure.
    Important Note : This function allows you to copy queries and their subobjects
    (structures, calculated key figures, and restricted key figures) between different InfoCubes. Note that the target InfoCube, that is the cube with the query copies, has to contain all the InfoObjects that are contained in the source InfoCube (InfoCube with the original queries)

  • Joins query between itab and database table..

    Hi all,
    Is it posible to use joins query between internle table and data base table...

    Hi Mehboob,
    No thats impossible to join the internal table and the database table.
    Alternatively what you need to do is you need to execute a Queryin Database Table and use the For All Entries in itab.
    Eg:  Select * from marc into table it_marc
             for all entries in it_matnr
               where matnr = it_matnr-matnr.
    Thanks,
    Chidanand

  • Parallel database connection​s and single query between databases

    Hi, I am looking to execute this SQL query between 2 different databases to update a local database based on data selected from a remote one.
    e.g.:
    - Local database name: db1
    - local database schema: dbo
    - local database table1
    - remote database name: db2
    - remote database schema: dbo
    - Remote database table: table2
    - Query: "SELECT * FROM db2.dbo.table2 WHERE NOT EXISTS(SELECT * FROM db1.dbo.table1)" <- This gets e the record set i would need to insert, and I already have a vi to do that kinda thing.
    How do I go about this?
    Thanks,
    Mohamed

    Mohamed,
    There is a VI in the Database Connectivity Toolkit that allows you to execute SQL queries:  DB Tools Execute Query.
    http://zone.ni.com/reference/en-XX/help/370016E-01​/lvdatabase/db_tools_execute_query/
    Is this what you are looking for?
    Drew T.
    NIC AE Specialist

  • Query between two tables : COAS and BPGE

    Hi,
    I want to create a Query between tables : COAS and BPGE but when i generate the Info-set the system had a problem of jointure. (the field OBJNR exist in the both)
    By this query i want to display the Order and the value of Budget
    Please Advise
    Regards

    hi..
    you can go with following type of code....
    select  coas~field1
               coas~field2
               bpge~field5
               bpeg~field6
    from    coas inner/outer join bpge
      on     coasobjnr = bpgeobjnr
    into      table t_table
    where condition
    hope this one will solve the issue
    regards

  • Urgent - I have written select query between loop and endloop, Ple help out

    Can any one help out me on this select query. I have written select query between loop and endloop. When I execute the program it will take too much time in this query. Please help me out. Its very urgent.
    LOOP AT l_i_invoices ASSIGNING <l_invoices>.
          CLEAR alv_wa.
          alv_wa-bukrs = <l_invoices>-bukrs.
          alv_wa-gsber = <l_invoices>-gsber.
          CLEAR l_instid.
          CONCATENATE <l_invoices>-belnr <l_invoices>-gjahr INTO l_instid.
          SELECT top_wi_id FROM sww_wi2obj INTO TABLE l_i_swwwihead
                  WHERE catid   = c_catid_business_object
                    AND instid  = l_instid
                    AND typeid  = c_typeid_invoice
                    AND removed = space
                    AND ( wi_rh_task = c_task_buyer_message
                       OR wi_rh_task = c_task_buyer_message2 ).
          IF sy-subrc = 0.
            <l_invoices>-flag = 'X'.
          ELSE.
            <l_invoices>-flag = ' '.
          ENDIF.
          MODIFY l_i_invoices FROM <l_invoices> TRANSPORTING flag
                                WHERE belnr = <l_invoices>-belnr
                                   AND gjahr = <l_invoices>-gjahr.
          APPEND alv_wa TO i_alv.
        ENDLOOP.
    Thanks in advance.

    Here is a way to solve this problem.
    Choose somewhere before this loop processing to use that select. Therefore, you'll need use FOR ALL ENTRIES <that_loop_table> clause, and in the WHERE condition you need to specify that same fields.
    This way, you will have an internal table with all data you'll need to check.
    Then, inside your loop statement, use the READ TABLE command with the clause WITH KEY field = value, to read that record and use the value found.
    Like this sample:
      SELECT bukrs lifnr umsks umskz augdt augbl zuonr gjahr belnr buzei
             waers xblnr blart gsber ebeln zfbdt zbd1t zlsch
      INTO TABLE tg_bsak
      FROM bsak
      FOR ALL ENTRIES IN tl_bkpf_sel
      WHERE bukrs EQ tl_bkpf_sel-bukrs AND
            lifnr IN s_lifnr AND
            augbl EQ tl_bkpf_sel-belnr.
    LOOP AT tg_bseg INTO wa_bseg.
        READ TABLE tg_bsak INTO wa_bsak WITH KEY bukrs = wa_bseg-bukrs
                                                 gjahr = wa_bseg-gjahr
                                                 belnr = wa_bseg-belnr
                                                 BINARY SEARCH.
    if sy-subrc = 0.
    * do something
    endif.
    ENDLOOP.

  • Query between two date columns ?

    Oracle 11g R2
    I'm trying too create a query between two date columns. I have a view that consists of many columns. There are two columns in question called valid_to and valid_from
    Part Number     Valid_from        valid_to
    100                    01/01/2000       01/01/9999
    200                    01/01/2000       01/01/9999
    300                    01/01/2000       01/01/9999
    etc
    If I want to only see rows between with a date range of 01/01/2000 and 01/01/2013 how can I put this as SQL ?
    Thanks in advance

    Hi,
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), so that the people who want to help you can re-create the problem and test their ideas.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    See the forum FAQ: https://forums.oracle.com/message/9362002
    If you want to find rows that have that exact range, then you can do  something like
    SELECT  *
    FROM    table_x
    WHERE   valid_from  = DATE '2000-01-01
    AND     valid_to    = DATE '2013-01-01'
    If you want to find rows where any or all or the range on the row overlaps any or all of the 200-2013 target range, then
    SELECT  *
    FROM    table_x
    WHERE   valid_from  <= DATE '2013-01-02
    AND     valid_to    >= DATE '2000-01-01'
    If you want rows that are enritely within the target range, it's something else.
    If you want rows that entirely enclose the target range, it's something else again.

  • Query between docdate and doctime

    Hi,
    I am having trouble in my query.I want to get the date that has date between 03/09/2015 and 03/10/2015 and time between 6:00AM of 03/09/2015 and 7:00AM of 03/10/2015 but it only show date with time between 6:00AM and 7:00Am of each date.
    This is my query
    SELECT T0.[DocDate], T0.[DocNum], T1.[Dscription], T1.[Quantity],T0.[DocTime] FROM OIGN T0  INNER JOIN IGN1 T1 ON T0.DocEntry = T1.DocEntry WHERE T0.[DocDate] between [%0] and [%1] and T0.[DocTime] >= [%2] and T0.[DocTime]<=[%3]
    Thanks,
    Raphael

    Hi Raphael Mendoza
    Have you check the database does it have data between those time slot...
    Also you use between option
    SELECT T0.[DocDate],
       T0.[DocNum],
       T1.[Dscription],
       T1.[Quantity],
       T0.[DocTime]
    FROM OIGN T0
    INNER JOIN IGN1 T1 ON T0.DocEntry = T1.DocEntry
    WHERE T0.[DocDate] BETWEEN [%0] AND [%1]
      AND T0.[DocTime] BETWEEN [%2] AND [%3]
    Regards
    Kennedy

  • Query between schemas

    We are migrating our application from SQL Server 2005 to ORacle 9i. We used to have queries that extracted data between different databases in SQL Server, we've encountered problems doing the same in ORacle. What used to be separate Databases in SQL Server appear now as different Schemas in Oracle. Ive read about Database Links and making use of them in our queries but Im not sure if this applies here since we are using the same database, just different schemas.
    I appreciate your help,
    JD

    JD,
    In FROM clause you can specify the schema, for example:
    SELECT *
    FROM s1.t1,
             s2.t2
    WHERE ...Also, you need to grant access accordingly. If the query is executed by user (schema) s1, then s1 must have SELECT privilege to read data in table s2.t2.
    GRANT SELECT ON s2.t2 TO s1Finally, you do a better job if you use roles, not granting privileges direct to users.
    Read about grants and roles.
    Regards,
    Miguel

  • Trouble With Query Between Dates:

    Hello Again,
    The query below is giving some trouble in that the line where 'CURRENT_DATE' is between 'START_DATE' and 'END_DATE.
    The query returns records close to those dates but some missing on the END_DATE. I was wondering if there is 'time at play here? How is only the date component used for the search?
    select * from (
    SELECT TO_CHAR (LEAVE.START_DATE, 'DD-MON-YY') AS Start_Date,
    TO_CHAR (LEAVE.END_DATE, 'DD-MON-YY') AS end_date,
    TO_CHAR (CURRENT_DATE, 'DD-MON-YY')AS CURRENT_DATE,
    LEAVE.NAME as NAME,
    LEAVE.ID as ID,
    LEAVE.DAYS as Days,
    LEAVE.SUPERVISOR as Supervisor,
    LEAVE.LEAVE_TYPE,
    FROM "LEAVE"
    WHERE CURRENT_DATE BETWEEN start_date AND end_date
    Kind Regards,
    Steve Welch

    Hi Steve,
    You should be aware that the Oracle datatype DATE also includes a time component.
    select to_char(current_date,'DD-MON-YYYY HH24:MI:SS') date_and_time from dual;
    DATE_AND_TIME       
    18-AUG-2011 13:29:49 Could it be that you are missing some records because they have a time which falls outside your condition?
    Regards
    Andre

  • SQL Query between two dates

    Hi,
    Please could someone help me on how to write a query to retrieve the data between two dates.
    created_date format stored in the database column: 9/18/2007 11:34:03 AM
    I tried below but it didn't work
    select * from work_table where created_date beween '9/18/2007' and '03/29/2008'
    I get 'literal doesn't match format string'
    Thanks,

    date datatype is nls dependent -> folllows the nls_date_format database parameter setting inherited by your session.
    Making it short you'll be always safe if you
    select * from work_table where created_date beween to_date('9/18/2007','MM/DD/YYYY') and to_date('03/29/2008','MM/DD/YYYY')Having the time component included you must add + 1 - 1 / 24 / 60 / 60 (plus one day minus one second) to the upper limit if you want to include the last day as a whole
    *** not tested
    Regards
    Etbin

  • Query between in partition table

    hello,
    i have been trying to get this query optmized when using BETWEEN.
    the below query has taking around 20 sec to execute, can someone suggest me
    to improve the performance?
    table is partioned with transaction_dt and have local index also statistics are collected.
      1  explain plan for
      2  SELECT *
      3    FROM Tb_Bookkeeping_Trans_Base
      4*  WHERE TRANSACTION_DT between '06-apr-10'  and '07-apr-2010'
    13:26:57 SQL> /
    Explained.
    Elapsed: 00:00:00.15
    13:26:58 SQL>
    13:26:58 SQL>
    13:27:01 SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3757902876
    | Id  | Operation                           | Name                           | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
    |   0 | SELECT STATEMENT                    |                                |   151K|    44M|  7363   (2)| 00:01:29 |       |       |
    |*  1 |  FILTER                             |                                |       |       |            |          |       |       |
    |   2 |   PARTITION RANGE ITERATOR          |                                |   151K|    44M|  7363   (2)| 00:01:29 |   KEY |    10
    |   3 |    TABLE ACCESS BY LOCAL INDEX ROWID| TB_BOOKKEEPING_TRANS_BASE      |   151K|    44M|  7363  
    |*  4 |     INDEX RANGE SCAN                | TB_BOOKKEEPING_TRANS_BASE_IDX2 |   154K|       |   757   (2)| 00:00
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       1 - filter('06-apr-10'<=TO_DATE(' 2010-04-07 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
       4 - access("TRANSACTION_DT">='06-apr-10' AND "TRANSACTION_DT"<=TO_DATE(' 2010-04-07 00:00:00', 's

    Something rather strange is happening to your date variables in the "Predicate Information" section below the plan.
    The first thing I would try is passing proper dates instead of character strings, i.e
    SELECT *
    FROM   tb_bookkeeping_trans_base
    WHERE  transaction_dt BETWEEN DATE '2010-04-06' AND DATE '2010-04-07'

Maybe you are looking for

  • How can I send a 10g report direct to the printer?

    Hi! I've got a form that calls n-times then same report, with different parameters. Actually, I generate a pdf and then, the user could print it.... but it is not a good idea, I want to send the output direct to the printer. do I have to register the

  • Datasource using com.evermind.sql.DriverManagerDataSource

    Is com.evermind.sql.DriverManagerDataSource still supported? If not can you direct me to documents on the new way of using datasources. In JDeveloper 10.1.3, "Embedded OC4J Server Preference -> Datasource" gives me three choices: Connection Pool,Mana

  • Issue with Faux Column solution for 2 Column website

    Hi - I hope you can help me I have come across a problem which I haven't seen before using the Faux Column method in DW CS5 - there is a white line appearing down the right side of my sidebar which I can only imagine is caused by the repeated backgro

  • Esc key not working with JDialog

    Hi, We are facing a KeyListening problem with JDialog. We developed an application using JRE 1.4.0. When we migrate from 1.4.0 to 1.4.2.The Esc keys(All keys) associated with the JDialog is not listening. Following is code piece is showing the Esc ke

  • Issues with vietnamese language

    Hi , I need help in locating the right font , NLS_LANG , database charactersets for a Vietnamese based forms application. I am having issues with VIETNAMESE_VIETNAM.VN8MSWIN1258 because some of the words are not coming properly in the forms . For exa