Date question (Oracle specific)

Results 1 to 3 of 3

Thread: Date question (Oracle specific)

  1. #1
    Join Date
    Dec 1969

    Default Date question (Oracle specific)

    I&#039;m still having trouble with Oracle&#039;s terrible date implementation. I am attempting to select all the records from a certain month or year. My SQL statement is:<BR><BR>&#060;%<BR>oConn.execute("select * from MyTable where datepart(yyyy, DueDate)=2001")<BR>%&#062;<BR>I get the error "ORA-00904: invalid column name". It seems as if the database is interpreting the whole thing as the field name. In other words, my field name is "DueDate" but it thinks the field name is "datepart(yyyy, DueDate)". The reason I believe that to be true is because it works just fine if I use this SQL statement:<BR>&#060;%<BR>oConn.execute("select * from MyTable where DueDate=2001")<BR>%&#062;<BR>But that doesn&#039;t give me the recordset that I need. Can anyone see any mistake I am making or point me to a decent FAQ on dates in Oracle.<BR><BR>Thank you!

  2. #2
    Join Date
    Dec 1969

    Default Just a shot in the dark

    How about:<BR><BR>oConn.execute("select * from MyTable where to_char(DueDate,&#039;YYYY&#039;)=2001")

  3. #3
    Join Date
    Dec 1969

    Default RE: Date question (Oracle specific)

    Try using the oracle specific functions<BR><BR>Select * from MyTable where TO_CHAR(DueDate, &#039;YYYY&#039;) = &#039;2001&#039;<BR><BR>Let me know if this does not work-<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts