p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Database > Oracle
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Oracle General Oracle database discussions.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 23rd, 2005, 08:55 AM
Registered User
 
Join Date: Aug 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL DATE-Format Problem

Hi,

i'm useing two tables:

project.id project.mandant
----------------------------
1 A
2 A
3 B
4 B

attr.id attr.name attr.value
----------------------------
1 DATE 12.01.2005
2 DATE 12.01.2005
3 DATE 12.01.2005 13:45:20
4 DATE 12.01.2005 13:47:20

The following SQL-Statement throw an error (ORA-01830).

select p.project_id, TO_DATE(a.value) AS SDATE
from project p, attr a
where p.mandant = 'A' and a.id = p.id
and a.name = 'DATE'
 and TO_DATE(a.value,'DD.MM.YYYY') >= TO_DATE('01.08.2005','DD.MM.YYYY')

How can i make oracle only look at the attr.id = 1 and attr.id = 2 ?

Greeting
Fritz


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old August 26th, 2005, 08:14 AM
Authorized User
 
Join Date: May 2005
Location: Berlin, CT, USA.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Fritz
 Hi,

i'm useing two tables:

project.id   project.mandant
----------------------------
1 A
2 A
3 B
4 B

attr.id   attr.name attr.value
----------------------------
1   DATE 12.01.2005
2   DATE 12.01.2005
3   DATE 12.01.2005 13:45:20
4   DATE 12.01.2005 13:47:20

The following SQL-Statement throw an error (ORA-01830).

select p.project_id, TO_DATE(a.value) AS SDATE
from project p,  attr a
where p.mandant = 'A' and a.id = p.id
and a.name = 'DATE'
 and TO_DATE(a.value,'DD.MM.YYYY') >= TO_DATE('01.08.2005','DD.MM.YYYY')

How can i make oracle only look at the attr.id = 1 and attr.id = 2 ?

Greeting
Fritz


Hi:

Change the line
Code:
TO_DATE(a.value) AS SDATE
to the following:
Code:
TO_DATE(a.value,'DD.MM.YYYY') AS SDATE
The problem is that the TO_DATE function doesn't recognize the data in your field properly... It needs to know which are the months, days, etc.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Date format problem abhishekkashyap27 C# 2005 1 June 23rd, 2008 03:25 AM
Sql Insert -- date format issue feets Access VBA 2 June 12th, 2007 01:11 PM
Date Format Problem Scripts82 Access VBA 2 March 13th, 2006 09:36 PM
Date format problem ERC Crystal Reports 1 June 15th, 2005 05:03 AM
Date format in ASP and in SQL 2000 Database phungleon Classic ASP Databases 1 December 23rd, 2004 12:57 AM



All times are GMT -4. The time now is 06:57 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc