Newbie SELECT WHERE DATE

Hello
I am new to SQL for Oracle,
So I am trying to run a simple query
SELECT * FROM ORCHP01DBO.WGN3EVENTAUDIT
WHERE EVENTTIMESTAMP = TO_DATE ('04/11/2012, 11:35:27 AM ') ;
Getting an error = ORA-01843: not a valid month
Here is how the EVENTTIMESTAMP column is formated
04/13/2000 10:10:48 AM
How can I correct it

>
You may want to try this:
SELECT * FROM ORCHP01DBO.WGN3EVENTAUDIT
WHERE EVENTTIMESTAMP = TO_DATE ('04/11/2012 11:35:27 AM ','DD/MM/YYYY HH:MI:SSAM') ;
>
Close - but probably not what OP wants to try.
OP said this
>
Here is how the EVENTTIMESTAMP column is formated
04/13/2000 10:10:48 AM
>
That would mean that the month is first where you show the day being first. So OP probably needs this
SELECT * FROM ORCHP01DBO.WGN3EVENTAUDIT
WHERE EVENTTIMESTAMP = TO_DATE ('04/11/2012 11:35:27 AM ','MM/DD/YYYY HH:MI:SS AM') ;

Similar Messages

  • Select where date current_date

    Hi, all
    I just tried to play with that select where I need to pick up records with TRADEDATE < 'CURRENT-DATE' and really impressed how intuituve Oracle is.
    tradedate date;
    SELECT * FROM TRADEMIX WHERE TRADEDATE <= (SELECT CURRENT_DATE FROM DUAL); works just fine, I see that even Month displayed as char 'SEP' treated in right collating order. Wow !!!
    So looks I don't need to do anything special ? It's my first experience with Oracle, so I just want to confirm that it's really the case.
    Also what will be the best way to do select only for TRADEDATE = ' 2010' (all records for give year)? Do I need to do any to_char for that? Not sure about correct syntax, all sample in texbook noted the whole date string 'DD-MON-YY'.
    Thanks
    Trent

    trento wrote:
    Hi, all
    I just tried to play with that select where I need to pick up records with TRADEDATE < 'CURRENT-DATE' and really impressed how intuituve Oracle is.
    tradedate date;
    SELECT * FROM TRADEMIX WHERE TRADEDATE <= (SELECT CURRENT_DATE FROM DUAL); works just fine, I see that even Month displayed as char 'SEP' treated in right collating order. Wow !!!
    So looks I don't need to do anything special ? It's my first experience with Oracle, so I just want to confirm that it's really the case.
    Also what will be the best way to do select only for TRADEDATE = ' 2010' (all records for give year)? Do I need to do any to_char for that? Not sure about correct syntax, all sample in texbook noted the whole date string 'DD-MON-YY'.
    Thanks
    TrentYou have some other examples for dealing with a just the year component of dates, but let me also point out a simpler form of what you have here:
    select * from trademix where tradedate <= sysdate;Just reference SYSDATE. No need to do a subselect against dual.
    And keep these things in mind:
    Oracle always stores DATE data in its internal format. That format includes both date and time.
    NSL_DATE_FORMAT, and the TO_DATE and TO_CHAR functions only deal with the presentation of the date.
    Play with this:
    alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
    select sysdate from dual;
    alter session set nls_date_format='dd-mon-yyyy hh24:mi:ss';
    select sysdate from dual;
    alter session set nls_date_format='yyyy-Mon-dd hh24:mi:ss';
    select sysdate from dual;
    alter session set nls_date_format='yyyy-MON-dd hh24:mi:ss';
    select sysdate from dual;
    alter session set nls_date_format='mm-dd-yyyy';
    select sysdate from dual;
    select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
    select to_char(sysdate,'dd-mon-yyyy hh24:mi:ss') from dual;
    select to_char(sysdate,'yyyy-Mon-dd hh24:mi:ss') from dual;Also keep firmly in mind that a character string is just that - a character string. No matter how much it may look like a date to you. Your keyboard is only capable of generating character strings. Your monitor is only capable of displaying character strings.

  • A question about select where date =

    I want to select data from a table which has a date column and has the time format like "2009-11-30 00:00:00.0".
    I try using the sql-script as follow but failed.
    select * from mytable
    where begin_date = to_date ('2009-11-30', 'yyyy.mm.dd ');
    Someone knows the format?

    Hi,
    user10501597 wrote:
    I want to select data from a table which has a date column and has the time format like "2009-11-30 00:00:00.0". All DATE columns have the same format; only strings have a format like that. A lot of people say they have a DATE column when they actually have a VARCHAR2 that is supposed to store a date. Post a CREATE TABLE statement to remove any doubt.
    I try using the sql-script as follow but failed.
    select * from mytable
    where begin_date = to_date ('2009-11-30', 'yyyy.mm.dd ');That looks okay. The extra space after dd shouldn't matter.
    What you wrote is equivalent to:
    select  *
    from    mytable
    where   begin_date = to_date ('2009-11-30 00:00:00', 'yyyy.mm.dd hh24:mi:ss');Are you sure you have rows with that value?
    Whenever you have a problem, post some sample data (CREATE TABLE and INSERT statements) so people can re-create the problem.

  • Select where date

    i set this in a when-button-press trigger and it compiled successfully but when i run the form i see the eror:
    SET_BLOCK_PROPERTY('SCH_PATIENT',DEFAULT_WHERE,'TRUNC(TO_DATE(reg_date,''DD-MON-YY'')) = '':rdate''' );
    FRM-40505 : oRACLE UNABLE TO PERFORM QUERY
    Please Advise

    try:
    SET_BLOCK_PROPERTY('SCH_PATIENT',DEFAULT_WHERE,'TRUNC(reg_date) = :rdate');
    NumbNutz

  • Selecting all data from employee where foreign key = null and show it in view

    Hi guys i have view like following :
    SELECT dbo.Nationality.NationalityName, dbo.Employee.DriverName, dbo.Employee.DriverID, dbo.Employee.NationalityID, dbo.Employee.ResidentNo,
    dbo.Country.CountryName, dbo.Employee.CountryID, dbo.Branch.BranchName, dbo.Employee.BranchID, dbo.Employee.JoinDate,
    dbo.Employee.ResignDate, dbo.Employee.HealthCarNo, dbo.Employee.JobID, dbo.Jobs.JobName, dbo.Department.DepartmentName,
    dbo.Jobs.DepartmentID, dbo.Employee.PlaceIssue, dbo.Employee.Deduction, dbo.Employee.ExpireDateMedical, dbo.Employee.PolicyNumber,
    dbo.Employee.Owner, dbo.Employee.Version, dbo.Employee.ExpireDateResident, dbo.Employee.Salary, dbo.Employee.SexID, dbo.Sex.SexType,
    dbo.Sex.FlagSex, dbo.Employee.MiritialID, dbo.Miritial.MiritualStatus, dbo.Status.StatusType, dbo.Employee.StatusID, dbo.Employee.UnactiveReason,
    dbo.Employee.BirthDate, dbo.Employee.DateToday, dbo.Employee.UserID, dbo.Employee.PassportNo, dbo.Employee.Period,
    dbo.Employee.AccountNo, dbo.Employee.Bonus, dbo.Employee.AccountType, dbo.Employee.PlaceOfBirth, dbo.Employee.EmplyeeName,
    dbo.Employee.ExpireDateresidentHijri, dbo.Employee.PassportDateStart, dbo.Employee.PassportDateExpire, dbo.Religon.ReligonName,
    dbo.Employee.ReligonID
    FROM dbo.Nationality INNER JOIN
    dbo.Employee ON dbo.Nationality.NationalityID = dbo.Employee.NationalityID INNER JOIN
    dbo.Country ON dbo.Employee.CountryID = dbo.Country.CountryID INNER JOIN
    dbo.Branch ON dbo.Employee.BranchID = dbo.Branch.BranchID INNER JOIN
    dbo.Jobs ON dbo.Employee.JobID = dbo.Jobs.JobID INNER JOIN
    dbo.Department ON dbo.Jobs.DepartmentID = dbo.Department.DepartmentID INNER JOIN
    dbo.Sex ON dbo.Employee.SexID = dbo.Sex.SexID INNER JOIN
    dbo.Miritial ON dbo.Employee.MiritialID = dbo.Miritial.MiritialID INNER JOIN
    dbo.Status ON dbo.Employee.StatusID = dbo.Status.StatusID INNER JOIN
    dbo.Religon ON dbo.Employee.ReligonID = dbo.Religon.ReligonID
    suppose i need to show all data from Employee table (NationalityName,BranchName,JobName) where
    NationalityID =NULL OR BranchID=NULL OR JobID=NULL
    WHAT I DO
    Notes : I mean in topic(selecting all data from view not table
    meaning i need to show all data in employee table by view
    in case of forign key(any forign key)equal null

    I think you need to change 
    FROM dbo.Nationality INNER JOIN
    dbo.Employee ON dbo.Nationality.NationalityID = dbo.Employee.NationalityID
    to
    FROM dbo.Nationality
    LEFT JOIN
    dbo.Employee ON dbo.Nationality.NationalityID = dbo.Employee.NationalityID
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Cannot select a Date in the 2nd week of any month from "Month View"

    Looking for some help with a strange problem that has started within the last day or 2. In Calendar, under the Month view, it will not allow me to select a date in the current week (or the second Week dates in ANY Month for that matter i.e. 6-8-08 thru 6-14-08, 8-3-08 thru 8-9-08, 4-6-08 thru 4-12-08). It skips from the 1st week of June (6-1-08 thru 6-7-08), to the 3rd and 4th weeks of June (6-15-08 thru the end of the month). It is like it is not recognizing where my finger is pointing. I can access the current week through the list view and day view, and it will allow me to post an event by choosing the current week in the add option, but will not let me pick that date to view it once it has been scheduled. The dot shows up, and it shows on list view, but cannot get to the date by selecting it in month view. That section of my phone screen will let me access other applications and recognize where I am touching, so I don't believe it is a sensor issue. I have tried rebooting, but it has not helped. Any ideas out there? Please let me know. Thank You! for any guidance.

    Clearwater Randy,
    If the screen is only not responding in that particular application, you may want to first do a reset. To reset, press and hold the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears.
    If that does not resolve your issue, try restoring in iTunes. To restore, connect your iPhone into iTunes and click Restore on the Summary page. Note: All of your information will be erased from the iPhone, so make sure to have a backup of important information on your computer before restoring.
    Hope this helps,
    Jennifer B.

  • To Select the data from two table one is transp table and onther is cluster

    Hi All,
    I want to select the data from two tables
    Here i am giving with an example.
    Fileds: kunnr belnr from bseg.  table bseg
    fields: adrnr from kna1     table: kna1.
    Know i want to put these into one internal table based on kunnr and belnr.
    Thanks in advance.
    Ramesh

    Hi,
       U cant use joins on cluster table and BSEG is a cluster table so use FOR  ALL ENTRIES for taht
    refer this code
    *&      Form  sub_read_bsak
          text
    -->  p1        text
    <--  p2        text
    FORM sub_read_bsak.
    *--Select data from BSAK Table
      SELECT lifnr
             augdt
             augbl
             gjahr
             belnr
             xblnr
             blart
             dmbtr
             mwskz
             mwsts
             sgtxt
             FROM bsak
             INTO CORRESPONDING FIELDS OF TABLE it_bsak
             WHERE belnr IN s_belnr
             AND   augdt IN s_augdt.
      IF sy-subrc EQ 0.
    *--Sort table by accounting document and vendor number
        SORT it_bsak BY belnr lifnr.
      ENDIF.
    ENDFORM.                    " sub_read_bsak
    *&      Form  sub_read_bseg
          text
    -->  p1        text
    <--  p2        text
    FORM sub_read_bseg.
      IF NOT it_bsak[] IS INITIAL.
    *--Select data from BSEG table
        SELECT belnr
               gjahr
               shkzg
               kostl
               hkont
               ebeln
               ebelp
               FROM bseg
               INTO CORRESPONDING FIELDS OF TABLE it_bseg
               FOR ALL ENTRIES IN it_bsak
               WHERE belnr EQ it_bsak-belnr
               AND   gjahr EQ it_bsak-gjahr
               AND   shkzg EQ 'S'.
        IF sy-subrc EQ 0.
    *--Sort table by accounting document
          SORT it_bseg BY belnr.
        ENDIF.
      ENDIF.
    ENDFORM.                    " sub_read_bseg

  • Beginners question - making sense of form, item, pane & variable (with relation to where data is stored in the SQL database)

    Hi Everyone,
    I am new to writing reports (SQL code) for SAP, however I am aware that inside SAP Business One it is necessary to enable System Information (from the View menu) in order to see which tables (and related table attributes / column names) are related to various aspects of the various SAP 'modules' (e.g.: A/R Invoice).
    Using an A/R Invoice as an example I can see at the row (or line) level that an item with the description of 'Opening Balance Transfer' is contained in the table INV1, within the attribute (or column) called Dscription.
    However not every 'on screen object' shows a table / attribute. For example in the same A/R Invoice if I hover my mouse over the Balance Due field all I see is Form related information.
    My question is 'How do I make sense of the Form, Item, Pane, Variable information?', with relation to where data is stored within the SQL database?
    Links to online tutorials explaining how this feature of SAP Business One will be much appreciated, along with any personal advice regarding working with this information.
    Any (and all) help will be greatly appreciated.
    Kind Regards,
    David

    Hi David,
    1.Here I am explaining use of each field except pane
    a. Form ---> Used in additional authorization creator
    b. Item, column--->Useful in creating Formatted search queries (FMS)
    c. Variable --> Some of the field values based on another values. ie. indirect values.
    d. INV1---Table name
    2. How to get variable?
    As per your second attachment, to get balance due ,you need doc total field from OINV table. For example,
    SELECT T0.[DocNum], T0.[DocTotal] FROM OINV T0 WHERE T0.[DocNum] = 612004797
    Thanks & Regards,
    Nagarajan

  • Select RTF Data and display in PDF Document

    Hi all,
    I have a simple table:
    CONTENT_ID - NUMBER
    CONTENT - VARCHAR2(4000)
    On top of this table I have a form that allows the user to enter / update data. The 'CONTENT' field is a Rich Text Editor (ApEx 4.0 - CKEditor 3). This allows the user to enter and format their text as they require.
    I need to be able to select this data and display it in a PDF Document (via BI Publisher).
    I therefore have a simple query
    select content from content_table where content_id = 1;and a simple template that processes the resulting xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <ROWSET>
       <ROW>
          <CONTENT>& lt;h2& gt;
         This is a heading& lt;/h2& gt;
    & lt;p& gt;
         This is the text& lt;/p& gt;
    </CONTENT>
       </ROW>
    </ROWSET>(There is not really a space between the & and 'lt' etc but I had to add this to get it to display correctly here).
    Where I run this past my template I get a PDF with:
    <h2>
    This is a heading</h2>
    <p>
    This is the text</p>I get the same if I generate HTML.
    but what I want to see is the text formatted as the user has entered in the RTF editor.
    Can this be done?
    Many thanks,
    Martin

    I think your mixing 2 technologies.
    At 1 side you have xml in combination with xsl (style sheets used in BI Publisher and FOP) to generate your pdf. And at the other side you have HTML...
    XML and HTML are 2 entirely different technologies which you can not mix this simple. I investigated the same problem as you had, and in the end I ended up using jasperreports instead of FOP.
    Maybe BI Publisher has some html regions which you could insert into your word document but I doubt it cause more people have asked the same question on this board...
    So my advice: use jasperreports (also it is free for commercial usage)
    Success
    Br,
    Nico

  • Since yesterday, clicking to read my email gets a blank window, not the email. Same w/ windows where data should be entered (like with online banking). Help!

    Since yesterday, when I click to read my email I get a blank window instead of the usual window with the email itself. The same is happening with windows where data should be entered, like those virtual keyboards for online banking login, or windows where you can add records (like daily electricity and gas consumption). In all these situations, a window should pop-up and pop-up it does - but always blank.
    I already unistalled/reinstalled Firefox and reset it "to its default state".
    Thanks in advance for your help.
    Miguel Sendim

    Hello,
    Many site issues can be caused by corrupt cookies or cache. In order to try to fix these problems, the first step is to clear both cookies and the cache.
    Note: ''This will temporarily log you out of all sites you're logged in to.''
    To clear cache and cookies do the following:
    #Go to Firefox > History > Clear recent history or (if no Firefox button is shown) go to Tools > Clear recent history.
    #Under "Time range to clear", select "Everything".
    #Now, click the arrow next to Details to toggle the Details list active.
    #From the details list, check ''Cache'' and ''Cookies'' and uncheck everything else.
    #Now click the ''Clear now'' button.
    Further information can be found in the [[Clear your cache, history and other personal information in Firefox]] article.
    Did this fix your problems? Please report back to us!
    Thank you.

  • Find data where data not in ref cursor

    CREATE OR REPLACE PACKAGE types AS
    TYPE weak_ref_cursor IS REF CURSOR;
    END types;
    CREATE OR REPLACE PROCEDURE procedure_name
    (p_getname OUT types.weak_ref_cursor,
    p_tablename IN VARCHAR2, p_salary IN NUMBER)
    AS
    v_tem VARCHAR2 (4000);
    BEGIN
    v_tem := 'SELECT ENAME FROM ' || UPPER (p_tablename) || ' WHERE sal > :b_salary';
    OPEN p_getname FOR v_tem USING p_salary;
    END procedure_name;
    SQL> EXECUTE procedure_name (:g_getname, 'EMP', 2000);
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.00
    SQL> print g_getname;
    ENAME
    ALLEN
    WARD
    MARTIN
    BLAKE
    babu
    JOHN
    TURNER
    7 rows selected.
    Now i want to select data from emp table where ename not in ouput of g_getname
    Please help me

    You cannot select that data from using a query(since the program unit is procedure), instead you can write a code (anonymous pl/sql block) and retrive the records and print them using dbms_output.put_line on console.

  • How do you keep the order using SELECT WHERE IN()?

    Hi,
    Is there a way to keep the order when using SELECT WHERE IN()? For example, using the following query:
    SELECT id FROM data_table WHERE id IN('56','55','54','1','7');
    The results will come back using the default order by id. 1,7,54,55,56
    When I want to keep the order used in the IN: 56,55,54,1,7
    Is there a quick way to do this in mySQL or will I be forced to order it after in code.
    Thanks

    797836 wrote:
    Hi,
    Is there a way to keep the order when using SELECT WHERE IN()? For example, using the following query:
    SELECT id FROM data_table WHERE id IN('56','55','54','1','7');
    The results will come back using the default order by id. 1,7,54,55,56In case the order by docs and comments weren't clear on this point, there is no default order and they may come back in a different order. Usually after you've tested it to exhaustion to prove otherwise, then put it in production.
    >
    When I want to keep the order used in the IN: 56,55,54,1,7
    Is there a quick way to do this in mySQL or will I be forced to order it after in code.
    ThanksUsing the in list allows oracle to have other possible data access paths than simply running the query 5 times. If for whatever reason you don't want to order the results after they come back, it may be worth your while to just run the five queries serially in the order you want, using bind variables and so having identical queries. That may seem silly on its face, but then again, we don't know the real requirements, what else is going on, if this is simplified from the real code or whether there will always be 5.

  • Selecting the data

    Hello All,
    I have the the query like this.
    select x2.trx_type_name,
    x2.trx_date
    from xla_ar_rec_ael_gl_v x1,
    XLA_AR_REC_AEL_SL_V x2
    where xlagl.trx_number_displayed = xlaar.trx_number_displayed(+);
    but i need to select the data from x1 also if there is no data in x2.
    how can i do this?Please help
    Thanks

    so please include this also with out changing my previous queryDon't have your tables and data, but that should come close:
    michaels>  SELECT empno FROM emp WHERE empno = 123
    no rows selected.
    michaels>  SELECT * FROM dept2
    no rows selected.
    michaels>  BEGIN
       FOR c IN (SELECT COLUMN_VALUE empno FROM TABLE (SYS.dbms_debug_vc2coll (7788)))
       LOOP
          INSERT INTO emp (empno)
             SELECT 123 FROM emp e, dept2
              WHERE c.empno = e.empno AND e.deptno = dept2.deptno(+);
       END LOOP;
    END;
    PL/SQL procedure successfully completed.
    michaels>  SELECT empno FROM emp WHERE empno = 123
         EMPNO
           123

  • Selecting the data without considering any case sensitives

    Moderator message: please do not post the same question more than once
    Hi,
    I need to select the data without considering any case sensitives.
    Eg: If i enter ***JoHn****, then system need to select all currencies or amount depending on the this name.
    Please assist, many thanks.
    Sameer.
    Edited by: Matt on Nov 20, 2008 1:16 PM

    Hi,
    use cp or like in the select query
    and more over any thing given in single quotes must be in upper case to my knowledge in ABAP.
    any how try this
    select * from dbtab where name like '%JoHn%'.
    if doesnt work translate it to upper case.
    hope this this would solve.
    regards
    Ramchander Rao.K

  • Need to select XMLTYPE data in unindented form, from a query.

    I need to select XMLTYPE data among relational data as an xml element.
    SELECT
      XMLSERIALIZE(DOCUMENT
      XMLELEMENT ("Account",
          XMLATTRIBUTES (LPAD(ROWNUM, 10 , '0')        AS "recordId"    )
           ,XMLELEMENT ("Header"
               ,XMLELEMENT ("AccountId"
                  ,XMLELEMENT ("AccountNumber"          ,car.acc_nbr              )))
                  ,XMLELEMENT ("CreditPurpose"            ,car.credit_purp           )
                 ,XMLELEMENT ("AccountType"              ,car.acc_type              )
                , (cdx.cus_dtls)  -- /*THIS IS XMLTYPE data*/
      ))AS crdtrpt
    FROM  cus_acc_rpt car , cus_dtls_xml cdx
    WHERE car.ar_id = cdx.ar_id
    Here cdx.cus_dtls need to be selected in unindented form (each records as a long unbroken string of data). So that I can SPOOL huge number of records in lesser time.
    I am trying to convert this into CLOB and Insert into CLOB type column of a table.
    But XMLSERIALIZE does not seem to serialize the xml data in cus_Dtls column.
    However it does serialize the xml typ data selected other than cus_dtls.
    Any quick hints to meet the requirements will be very welcomed !!
    Cheers !!
    Saxena

    Use XMLSerialize with NO INDENT option :
    SELECT XMLSERIALIZE(DOCUMENT
             XMLELEMENT ("Account",
             NO INDENT
           )AS crdtrpt
    FROM  cus_acc_rpt car , cus_dtls_xml cdx
    WHERE car.ar_id = cdx.ar_id

Maybe you are looking for