LIKE Operator to ignore the time part of DATE type?

Hi,
is it allowed to use the LIKE operator on DATE Type to ignore the time-part in the DATE?
Nothing found in the manual, but seems to me that it works.
1. SELECT * FROM test_date WHERE tst_date LIKE to_date('01.01.2003 13:33:33','DD.MM.YYYY HH24:MI:SS') ;
2. SELECT * FROM test_date WHERE tst_date LIKE to_date('01.01.2003','DD.MM.YYYY') ;
3. SELECT * FROM test_date WHERE tst_date LIKE trunc(to_date('01.01.2003 00:00:00','DD.MM.YYYY HH24:MI:SS'));
4. SELECT * FROM test_date WHERE to_date('01.01.2003 13:33:33','DD.MM.YYYY HH24:MI:SS') LIKE tst_date;
5. SELECT * FROM test_date WHERE tst_date BETWEEN to_date('01.01.2003 00:00:00','DD.MM.YYYY HH24:MI:SS') AND to_date('01.01.2003 23:23:59','DD.MM.YYYY HH24:MI:SS');
6. SELECT * FROM test_date WHERE tst_date >= TO_DATE('01.01.2003 00:00:00','DD.MM.YYYY HH24:MI:SS') AND tst_date < TO_DATE('01.01.2003')+1;
7. SELECT * FROM test_date WHERE TRUNC(tst_date) = TRUNC(TO_DATE('01.01.2003 00:00:00','DD.MM.YYYY HH24:MI:SS'));
Result for 1-7 is the same.
What is the preferred Solution?
Solution 5 is bad, because index on TST_DATE column could not be used.
Solution 1 - 3 is the same using the LIKE operator.
Any comments?
Thanks, Markus
GEMS IT

Oh, sorry, LIKE-Operator solutions do also not use an Index :-(. Only 5. and 6.
Sample-Script:
CREATE TABLE TEST_DATE
TST_DATE DATE
CREATE INDEX MEDVIEW.TEST_DATE_IDX
ON MEDVIEW.TEST_DATE(TST_DATE);
INSERT INTO TEST_DATE ( TST_DATE ) VALUES (
TO_Date( '01/01/2003 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO TEST_DATE ( TST_DATE ) VALUES (
TO_Date( '01/01/2003 12:45:13 PM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO TEST_DATE ( TST_DATE ) VALUES (
TO_Date( '01/01/2003 08:11:55 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO TEST_DATE ( TST_DATE ) VALUES (
TO_Date( '01/01/2003 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO TEST_DATE ( TST_DATE ) VALUES (
TO_Date( '01/01/2003 09:33:16 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO TEST_DATE ( TST_DATE ) VALUES (
TO_Date( '01/02/2003 07:45:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO TEST_DATE ( TST_DATE ) VALUES (
TO_Date( '01/02/2003 07:33:00 PM', 'MM/DD/YYYY HH:MI:SS AM'));
COMMIT;

Similar Messages

  • SQL Developer is not exporting the time part of date data types.

    I need to export data from a table using sql developer. The column is a date data type but when I export the data to a csv, xls or an sql file with insert statements, sql developer only includes the date part without the time.
    Please kindly advise.
    Thanks,
    Erika

    What is your 4 digits Oracle version ?
    What is your SQL Developer version ?
    With Oracle XE and a schema named TEST I have:
    select * from t
    X                        
    04-FÉVR.-2010 21:24:40  If I use Tools/Database Export with all default settings with SQL Developer 2.1.0.63 I get following SQL file:
    --  Fichier créé - jeudi-février-04-2010  
    --  DDL for Table T
      CREATE TABLE "T"
       (     "X" DATE
    --   DATA FOR TABLE T
    --   FILTER = none used
    REM INSERTING into T
    Insert into T (X) values (to_timestamp('04/02/10 21:24:40,000000000','DD/MM/RR HH24:MI:SS,FF'));
    --   END DATA FOR TABLE T
    ---------------------------------------------------Edited by: P. Forstmann on 4 févr. 2010 21:26

  • How do you add time to the time part of date in oracle

    Guys:
    I need to add 5 hours to the date in a date column. I did it the foll. way.
    for ex:
    select to_char(sysdate, 'mm/dd/yy hh:mi:ss'), to_char((sysdate + (5/24)), 'mm/dd/yy hh:mi:ss;) from dual;
    It works! The second column shows that 3 hours has been added to the time. I am wondering if there is a better way to do it. Any tips/suggestions please.....
    I use SQL Server a lot and they have the Dateadd function to add to ay part of the datetime such as day, motnh, year, hours, minutes, etc.

    Not Sure !
    But, try
    dtefield + 5/24
    This will dd 5/24 day !

  • Error In IR at the time of activating data types

    I am getting an error at teh time of activating the data type
    Namespace urn:rfctoftpserver:am is not defined in the software component version SAP_ECC_DABUR_POS , 9.5 of sap.com.
    How ever I have saved the name space in Display Software component version!!
    Pls help!

    Hello,
    This problem basically happen due to the following reasons:
    1) when you try to copy the datatype from one Object to other and the namespace is not activated in course of it.
    2) If you have deleted the datatype but it still remains in the Objects list
    Resolution:
    1) Try to change the datatype name and activate
    2) if it still doesn't work have a look at the Software component relation with the datatype namespace relation

  • Why the 'LIKE' operator takes so much time to run?

    I have a table T with 3 columns and 3 indexes:
    CREATE TABLE T
    id VARCHAR2(38) NOT NULL,
    fid VARCHAR2(38) NOT NULL,
    val NVARCHAR2(2000) NOT NULL
    ALTER TABLE T ADD (CONSTRAINT pk_t PRIMARY KEY (id,fid));
    CREATE INDEX t_fid ON T(fid);
    CREATE INDEX t_val ON T(val);
    Then I have the following two queries which differ in only one place - the 1st one uses the '=' operator whereas the 2nd uses 'LIKE'. Both queries have the identical execution plan and return one identical row. However, the 1st query takes almost 0 second to execute, and the 2nd one takes more than 12 seconds, on a pretty beefy machine. I had played with the target text, like placing '%' here and/or there, and observed the similar timing every time.
    So I am wondering what I should change to make the 'LIKE' operator run as fast as the '=' operator. I know CONTEXT/CATALOG index is a viable approach, but I am just trying to find out if there is a simpler alternative, such as a better use of the index t_val.
    1) Query with '=' operator
    SELECT id
    FROM T
    WHERE fid = '{999AE6E4-1ED9-459B-9BB0-45C913668C8C}'
    AND val = '3504038055275883124';
    2) Query with 'LIKE' operator
    SELECT id
    FROM T
    WHERE fid = '{999AE6E4-1ED9-459B-9BB0-45C913668C8C}'
    AND val LIKE '3504038055275883124';
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=1 Card=1 Bytes=99)
    1 0 TABLE ACCESS (BY INDEX ROWID) OF 'T' (Cost=1 Card=1 Bytes=99)
    2 1 INDEX (RANGE SCAN) OF 'T_VAL' (NON-UNIQUE) (Cost=4 Card=12)

    I will for sure try to change the order of the PK and see whether there will be any impact to the performance.
    In our application, val is much closer to a unique value than fid. In the example query, the execution plan showed that the index on val was indeed used in the execution of the query. That's why the 1st query took almost no time to return (our table T has more than 6 million rows).
    I was hoping the 'LIKE' operator would utilize the t_val index effectively and provide similar performance to the '=' operator. But apparently that's not the case, or needs some tricks.

  • GetDate of resultset Ignoring the Time (hors min secs) component in DB2

    Hello I have a DB2 in which has the date in the format 2007-01-24 09:25:21.680000.
    I am trying to retrevie it using the
    java.sql.Date start =rs.getDate("Give_time");
    System.out.println("This is the Start Time Stamp" + startBuild.getTime());
    Gives me the Timestamp of the "2007-01-24" completely ignoring the time "09:25:21" which is more important to me in this case.
    How do I retreve the time in the date ?

    If you mean getTimeWell actually no he meant getTimestamp but that doesn't seem to be your real issue.
    There are three kinds of date/time objects in JDBC/SQL. One is a Date (that holds only the Date information), one is a Time (that holds only Time information) and last is a Timestamp (that holds both).
    So if you want to get the time you need use getTimestamp or getDate methods. However as mentioned you also need to
    - have a field that is actually storing this information
    - actually be storing this field
    So one of those two looks like in your case it isn't correct.

  • Adding one day to a oracle.jbo.domain.Date and truncating the time part

    JDev 11.1.1.4.0
    Hello
    I need to add a day to oracle.jbo.domain.Date and get back a oracle.jbo.domain.Date without the time part.
    So far I've got
    Date valueDate = (Date)rowCpt.getAttribute("ValueDate");                                       
    Calendar cal = Calendar.getInstance();
    cal.setTime(new java.util.Date(valueDate.timestampValue().getTime()));
    cal.add(Calendar.DATE, 1);
    Date newDate = new oracle.jbo.domain.Date(new Timestamp(cal.getTime().getTime()));This adds 1 day to the date but keeps the time part of the date.
    How do I get rid of the time part of the date ?
    Thanks
    Paul

    The Calendar class allows you to set or clear each field.
    Date valueDate = (Date)rowCpt.getAttribute("ValueDate");                                       
    Calendar cal = Calendar.getInstance();
    cal.setTime(new java.util.Date(valueDate.timestampValue().getTime()));
    cal.add(Calendar.DATE, 1);
    cal.clear(Calendar.HOUR);
    cal.clear(Calendar.MINUTE);
    cal.clear(Calendar.SECOND);
    cal.clear(Calendar.MILLISECOND);
    Date newDate = new oracle.jbo.domain.Date(cal.getTimeInMillis());should work.
    Timo

  • The fan on my air Processor  1.7 GHz Intel Core i5 seems like it on all the time and loud

    the fan on my air Processor  1.7 GHz Intel Core i5 seems like it on all the time and loud

    Fan
    The computer's fans run at high speed although the computer is not experiencing heavy usage and is properly ventilated.
    Reset SMC.     http://support.apple.com/kb/HT3964
    Choose the method for:
    "Resetting SMC on portables with a battery you should not remove on your own".
    Best.

  • Can you set the 'time, day, AND DATE' in menu bar ?

    I note that the DAY and Time are in my menu bar (top line of screen), I would find it more than handy to be able to have the DATE also there , there has GOT to be a simple answer ?????.
    I am having fun learning a 'new' (to me) system....the wife is now a computer widow !!!
    iMac G5   Mac OS X (10.4.4)  

    Click the Time - greyed out date.
    Just like a real wife -
    they don't tell you everything unless you ask ... in the right way.

  • When I change the time zone of the clock, the "Date created" time information for my documents and image files in the Finder window (and in Get Info) is changed. Can I make the time info in "Date created" remain fixed regardless of the clock's timezone?

    When I change the time zone of the clock, the "Date created" time information for my documents and image files in the Finder window (and in Get Info) is changed. Can I make the time info in "Date created" remain fixed regardless of the clock's timezone?

    When I change the time zone of the clock, the "Date created" time information for my documents and image files in the Finder window (and in Get Info) is changed. Can I make the time info in "Date created" remain fixed regardless of the clock's timezone?

  • Not able to terminate an Emp, Error: The person must exist as an employee at the time specified by Date Start

    HI Guru's
    We are sourcing Employee records from upstream system and the Effective_start_date for particular record of Employee is getting changed, consider a below scenario.
    EXISTING RECORD.
    Person_id, effective_start_date,Effective_end_date, person_type
    123,       01-JAN-2001         ,31-MAY-2001,        EMP
    123,       01-JUN-2001         ,31-DEC-4712,        EMP
    MODIFIED DRECORD
    Person_id, effective_start_date,Effective_end_date, person_type
    123,       01-JAN-2001         ,14-MAY-2001,        EMP
    123,       15-MAY-2001         ,31-DEC-4712,        EMP
    So when i am able to change the effective_start_date for 2nd record from 01-JUN-2001 to 15-MAY-2001 using an API "hr_person_api.update_person" with p_datetrack_update_mode as 'UPDATE_OVERRIDE'..
    but after this when i am trying to terminate the employee using an API "hr_ex_employee_api.actual_termination_emp" for below scenario, i am getting the following error: "The person must exist as an employee at the time specified by Date Start".
    For Termination:
    Person_id, effective_start_date,Effective_end_date, person_type
    123,       01-JAN-2001         ,14-MAY-2001,        EMP
    123,       15-MAY-2001        ,09-JUL-2001,        EMP
    123,       10-JUL-2001         ,31-DEC-4712,       EX_EMP  ----> Not able to process erroing
    Please help me in resolving this issue..
    Regards,
    Mushtaq

    Hi,
    Just wondering if this is an ATG related question.
    Thanks,
    Gopinath Ramasamy

  • Regarding the Time dependent master data error

    Hi Masters,
            I've loaded the time dependent master data from flat file only two fields. When I checked that corresponding characteristics in maintain master data, that contains by default from date 01.01.2007and to date 31.12.9999 this date also. Could you please help me to rectify this error.
    Thanks in advance
    Raja.S

    Hi Antonino La Vela
          I have 2 Project Manger and in different duration for different project.
    Following datas are my data in Excel sheet.
    PM Name                    To date             From Date           Costcenter
    Ragunath                    01.09.2007        01.06.2006           Project name1
    Ramana mani              01.02.2008         02.09.2007          Project name2
    while loading above data, I'm getting following data in maintain master data
    PM name                   To Date             From Date           Costcenter
                                     31.12.9999         01.01.1000
    Ragunath                   31.05.2007         01.01.1000
    Ragunath                   01.09.2007         01.06.2007            Project Name1
    Ragunath                   31.12.9999         02.09.2007 
    Ramana mani             01.09.2007          01.01.1000
    Raman mani               01.02.2008          02.09.2007           Project Name2
    Raman mani               31.12.9999           02.02.2008   
    Could you please help me, how this unnecessary datas are loaded by default?
    Thanks in Advance
    Raja.S

  • As to the data type of the data type of the difference between two date type of datas

    Hi,
    I have a question about the data type of the difference between two date type of datas.
    There are two date type of datas as:
    SSHIPMENTS.RECEIVEDATETIME
    SSHIPMENTS.PROMISEDATETIME
    I try to use the following SQL Script in Oracle SQL*Plus as:
    SELECT CASE
    WHEN (SSHIPMENTS.RECEIVEDATETIME - SSHIPMENTS.PROMISEDATETIME) < '000 01:00:00.000' THEN 'OnTime'
    WHEN (SSHIPMENTS.RECEIVEDATETIME - SSHIPMENTS.PROMISEDATETIME) < '000 01:30:00.000' THEN '60-89 Minutes'
    ELSE '3+ Hours'
    END
    FROM SSHIPMENTS;
    The error message of "Invalid Number" for the '000 01:30:00.000' happens.
    I don't know if the data type of the interval is wrong.
    Many Thanks,
    Cathy

    SELECT CASE
    WHEN (to_char(SSHIPMENTS.RECEIVEDATETIME,'hhmiss') - to_char(SSHIPMENTS.PROMISEDATETIME,'hh24miss')) < '010000' THEN 'OnTime'
    WHEN (to_char(SSHIPMENTS.RECEIVEDATETIME,'hhmiss') - to_char(SSHIPMENTS.PROMISEDATETIME,'hh24miss'))< '000 01:30:00.000' THEN '60-89 Minutes'
    ELSE '3+ Hours'
    END
    FROM SSHIPMENTS;
    just try it out..

  • How to dump table to the flat file, if the table has NVARCHAR data type fie

    I need to dump the table to the text file. The table has NVARCHAR data type field and simple select * from table_name does not work. What do I have to do? Do I need convert NVARCHAR to VARCHAR and if yes, then how?
    Thanks,
    Oleg

    I need to dump the table to the text file. The table has NVARCHAR data type field and simple select * from table_name does not work. What do I have to do? Do I need convert NVARCHAR to VARCHAR and if yes, then how?
    Thanks,
    Oleg

  • What is the size of number data type.

    what is the size of number data type (in term of memory storage ;byte ).
    Does it make different in size if mention number(38,0)?
    Thanks all in advance...:)
    Edited by: user10648897 on Jan 7, 2009 6:43 AM

    NUMBER (p,s)
    Number having precision p and scale s. The precision p can range from 1 to 38. The scale s can range from -84 to 127.number(38,0) = number(38)
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14196/schema002.htm#sthref472

Maybe you are looking for

  • Cannot connect to 4G network after update to OS 10.3.1

    Have a Q10 through Sprint and after updating to OS 10.3.1 from the Blackberry site, phone will now only connect to 3G network despite availablity of 4G network. Phone used to connect to 4G network with OS 10.2,

  • Can't update my iPod Touch to 3.1 (Windows 7 here). Help

    Every time I try to update my iPod Touch to 3.1 it says that an error occurred (says "error 14) and then I can't update my iPod. It is now useless without any system. Help!!! BTW, I'm on Windows 7.

  • How to execute a application folder with space

    Hi All, Can any one help to execute the application folder or a file that contains space. Below I have pated my sample coding: var myFile=new File("/E/test text/lanch.app"); myFile.exceute(); If I remove the space between "test test", it works perfec

  • Question about the Zone Tabs.

    <Current Situation> I use the Zone Tabs Web Part in SharePoint 2010. I am considerring about migration from SharePoint 2010 to Sharepoint 2013(Sharepoint 2010 experience). I would like to evaluate whether the Zone Tabs is available in Sharepoint 2013

  • Alerts management

    Hi All, How to use this Alerts management? When this will be used? Will this send an e-mail to the users ? Regards,