Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > Oracle
|
Oracle General Oracle database discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 23rd, 2005, 07:55 AM
Registered User
 
Join Date: Aug 2005
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


 
Old August 26th, 2005, 07:14 AM
Authorized User
 
Join Date: May 2005
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.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Date format problem abhishekkashyap27 C# 2005 1 June 23rd, 2008 02:25 AM
Sql Insert -- date format issue feets Access VBA 2 June 12th, 2007 12: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 04:03 AM
Date format in ASP and in SQL 2000 Database phungleon Classic ASP Databases 1 December 23rd, 2004 12:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.