RE: To_Char Problem

2002-08-16 Thread Jacques Kilchoer
Title: RE: To_Char Problem





a) Do not convert date fields to characters in a comparison. In your query, use
and a.updated_date = (select max(updated_date) ...
b) If you absolutely want to create two character strings from a date, and then compare the strings, this is the format to use:

to_char (date1, 'S/MM/DD HH24:MI:SS')  to_char (date2, 'S/MM/DD HH24:MI:SS')
or
to_char (date1, 'SMMDDHH24MISS')  to_char (date2, 'SMMDDHH24MISS')


 -Original Message-
 From: karthikeyan S [mailto:[EMAIL PROTECTED]]
 
 I am using the to_char function in the following query. But 
 it treats the date '31/12/2001' as greater than '01/01/2002'. 
 Is there any solution to fix this problem? 
 
 select distinct(a.default_type_id), a.new_val 
 from amend_default_value a, amend_default_value b
 where a.effective_from = sysdate and
 a.effective_to = sysdate and
 a.group_id = '942' and
 a.default_type_id = b.default_type_id and
 to_char(a.updated_date,'dd/mm/ hh:mi:ss') = 
 ( select max(to_char(updated_date,'dd/mm/ hh:mi:ss')) 
 from amend_default_value c
 where c.effective_from = sysdate and
 c.effective_to = sysdate and
 c.group_id = '942' and
 c.default_type_id = b.default_type_id);





RE: To_Char Problem

2002-08-14 Thread Nicoll, Iain (Calanais)

Why do you need the to_char?

But wouldn't it work anyway with 

to_char(a.updated_date,'dd/mm/ hh24:mi:ss') = 
   ( select to_char(max(updated_date),'dd/mm/ hh24:mi:ss'))

which will also use the 24 hour clock instead of

to_char(a.updated_date,'dd/mm/ hh:mi:ss') = 
   ( select max(to_char(updated_date,'dd/mm/ hh:mi:ss'))


Iain Nicoll


-Original Message-
Sent: Wednesday, August 14, 2002 5:54 PM
To: Multiple recipients of list ORACLE-L


Hi All,

I am using the to_char function in the following query.  But it treats the
date '31/12/2001' as greater than '01/01/2002'. 
Is there any solution to fix this problem? 
 
 select distinct(a.default_type_id), a.new_val   
 from amend_default_value a, amend_default_value b
 where a.effective_from = sysdate and
   a.effective_to= sysdate and
   a.group_id = '942'   and
   a.default_type_id = b.default_type_id and
   to_char(a.updated_date,'dd/mm/ hh:mi:ss') = 
   ( select max(to_char(updated_date,'dd/mm/ hh:mi:ss')) 
   from amend_default_value c
   where c.effective_from = sysdate and
   c.effective_to= sysdate and
   c.group_id = '942' and
   c.default_type_id = b.default_type_id);

Thanks in advance. 

regards,
Karthik 

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: karthikeyan S
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Nicoll, Iain (Calanais)
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).



Re: To_Char Problem

2002-08-14 Thread Babu . Nagarajan


Why would you want to do that - convert two dates into a char and then
compare them ? This is not a problem but it is how char comparisions work.
They are compared char by char to see which one is greater on the ASCII
chart.

See this : SQL  select '1' from dual where '3'  '10';

'
-
1

Babu





karthikeyan S [EMAIL PROTECTED]@fatcity.com on 08/14/2002 11:53:53
AM

Please respond to [EMAIL PROTECTED]

Sent by:[EMAIL PROTECTED]


To:Multiple recipients of list ORACLE-L [EMAIL PROTECTED]
cc:



Hi All,

I am using the to_char function in the following query.  But it treats the
date '31/12/2001' as greater than '01/01/2002'.
Is there any solution to fix this problem?

 select distinct(a.default_type_id), a.new_val
 from amend_default_value a, amend_default_value b
 where a.effective_from = sysdate and
   a.effective_to= sysdate and
   a.group_id = '942'   and
   a.default_type_id = b.default_type_id and
   to_char(a.updated_date,'dd/mm/ hh:mi:ss') =
   ( select max(to_char(updated_date,'dd/mm/ hh:mi:ss'))
   from amend_default_value c
   where c.effective_from = sysdate and
   c.effective_to= sysdate and
   c.group_id = '942' and
   c.default_type_id = b.default_type_id);

Thanks in advance.

regards,
Karthik

--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: karthikeyan S
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).




-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: 
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).



Re: To_Char Problem

2002-08-14 Thread Joe Testa

because it is.

its not a problem with oracle, its a problem with the way the query is 
written.

make the date mask /MM/DD HH24:MI:SS instead.

last i checked in math101, a number(or character string) 8 digits long, 
that starts with a 31 is larger than an 8 digit number starting with 01.

joe


karthikeyan S wrote:

Hi All,

I am using the to_char function in the following query.  But it treats the date 
'31/12/2001' as greater than '01/01/2002'. 
Is there any solution to fix this problem? 
 
 select distinct(a.default_type_id), a.new_val   
 from amend_default_value a, amend_default_value b
 where a.effective_from = sysdate and
   a.effective_to= sysdate and
   a.group_id = '942'   and
   a.default_type_id = b.default_type_id and
   to_char(a.updated_date,'dd/mm/ hh:mi:ss') = 
   ( select max(to_char(updated_date,'dd/mm/ hh:mi:ss')) 
   from amend_default_value c
   where c.effective_from = sysdate and
   c.effective_to= sysdate and
   c.group_id = '942' and
   c.default_type_id = b.default_type_id);

Thanks in advance. 

regards,
Karthik 




-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Joe Testa
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).



Re: To_Char Problem

2002-08-14 Thread Joe Testa

because it is.

its not a problem with oracle, its a problem with the way the query is 
written.

make the date mask /MM/DD HH24:MI:SS instead.

last i checked in math101, a number(or character string) 8 digits long, 
that starts with a 31 is larger than an 8 digit number starting with 01.

joe


karthikeyan S wrote:

Hi All,

I am using the to_char function in the following query.  But it treats the date 
'31/12/2001' as greater than '01/01/2002'. 
Is there any solution to fix this problem? 
 
 select distinct(a.default_type_id), a.new_val   
 from amend_default_value a, amend_default_value b
 where a.effective_from = sysdate and
   a.effective_to= sysdate and
   a.group_id = '942'   and
   a.default_type_id = b.default_type_id and
   to_char(a.updated_date,'dd/mm/ hh:mi:ss') = 
   ( select max(to_char(updated_date,'dd/mm/ hh:mi:ss')) 
   from amend_default_value c
   where c.effective_from = sysdate and
   c.effective_to= sysdate and
   c.group_id = '942' and
   c.default_type_id = b.default_type_id);

Thanks in advance. 

regards,
Karthik 




-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Joe Testa
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).



RE: To_Char Problem

2002-08-14 Thread Amjad Saiyed

try this

 select distinct(a.default_type_id), a.new_val   
 from amend_default_value a, amend_default_value b
 where a.effective_from = sysdate and
   a.effective_to= sysdate and
   a.group_id = '942'   and
   a.default_type_id = b.default_type_id and
   a.updated_date = 
   ( select max(updated_date) 
   from amend_default_value c
   where c.effective_from = sysdate and
   c.effective_to= sysdate and
   c.group_id = '942' and
   c.default_type_id = b.default_type_id);

dont use to_char at all.

rgds,
Ams.

-Original Message-
Iain (Calanais)
Sent: Wednesday, August 14, 2002 9:55 PM
To: Multiple recipients of list ORACLE-L


Why do you need the to_char?

But wouldn't it work anyway with 

to_char(a.updated_date,'dd/mm/ hh24:mi:ss') = 
   ( select to_char(max(updated_date),'dd/mm/ hh24:mi:ss'))

which will also use the 24 hour clock instead of

to_char(a.updated_date,'dd/mm/ hh:mi:ss') = 
   ( select max(to_char(updated_date,'dd/mm/ hh:mi:ss'))


Iain Nicoll


-Original Message-
Sent: Wednesday, August 14, 2002 5:54 PM
To: Multiple recipients of list ORACLE-L


Hi All,

I am using the to_char function in the following query.  But it treats the
date '31/12/2001' as greater than '01/01/2002'. 
Is there any solution to fix this problem? 
 
 select distinct(a.default_type_id), a.new_val   
 from amend_default_value a, amend_default_value b
 where a.effective_from = sysdate and
   a.effective_to= sysdate and
   a.group_id = '942'   and
   a.default_type_id = b.default_type_id and
   to_char(a.updated_date,'dd/mm/ hh:mi:ss') = 
   ( select max(to_char(updated_date,'dd/mm/ hh:mi:ss')) 
   from amend_default_value c
   where c.effective_from = sysdate and
   c.effective_to= sysdate and
   c.group_id = '942' and
   c.default_type_id = b.default_type_id);

Thanks in advance. 

regards,
Karthik 

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: karthikeyan S
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Nicoll, Iain (Calanais)
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).


-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Amjad Saiyed
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).