SQL [message #619986] |
Sun, 27 July 2014 07:20 |
ORAGENASHOK
Messages: 240 Registered: June 2006 Location: Chennai
|
Senior Member |
|
|
select c1, c2
from table t1,t2
where t1.id = t2.id and
to_char(t1.dtm_val,'dd-mon-yyyy H24:MM:SS') between to_char('02-jun-2014 14:12:03','dd-mon-yyyy H24:mm:ss') and
to_char('02-jun-2014 14:12:03','dd-mon-yyyy H24:mm:ss')
Getting ORA-01722 invalid number
I think i have given right value?
|
|
|
Re: SQL [message #619987 is a reply to message #619986] |
Sun, 27 July 2014 07:28 |
John Watson
Messages: 8931 Registered: January 2010 Location: Global Village
|
Senior Member |
|
|
This
Quote:to_char('02-jun-2014 14:12:03','dd-mon-yyyy H24:mm:ss') is attempting to convert string to a string.
|
|
|
Re: SQL [message #619989 is a reply to message #619986] |
Sun, 27 July 2014 07:32 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
ORAGENASHOK wrote on Sun, 27 July 2014 17:50and
to_char(t1.dtm_val,'dd-mon-yyyy H24:MM:SS') between to_char('02-jun-2014 14:12:03','dd-mon-yyyy H24:mm:ss') and
to_char('02-jun-2014 14:12:03','dd-mon-yyyy H24:mm:ss')
Assuming, t1.dtm_val is a DATE data type.
and t1.dtm_val between to_date('02-jun-2014 14:12:03','dd-mon-yyyy H24:mi:ss')
and to_date('02-jun-2014 14:12:03','dd-mon-yyyy H24:mi:ss')
Another thing, the time part having minutes should be "mi" and not "mm", it is months in 2 digits.
Regadrs,
Lalit
Edit : Modified "mm" to "mi" with reason explained.
[Updated on: Sun, 27 July 2014 07:36] Report message to a moderator
|
|
|
|
Re: SQL [message #619995 is a reply to message #619992] |
Sun, 27 July 2014 07:56 |
John Watson
Messages: 8931 Registered: January 2010 Location: Global Village
|
Senior Member |
|
|
I'm sure you can debug Lalit's minor typing error. Look up the data picture formats.
|
|
|
|
Re: SQL [message #619997 is a reply to message #619995] |
Sun, 27 July 2014 08:05 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
John Watson wrote on Sun, 27 July 2014 18:26I'm sure you can debug Lalit's minor typing error. Look up the data picture formats.
Actually I just copy pasted OP's predicate, so didn't notice the missing "h". Even Michel noticed something more logical than the technical things we pointed. There are so many things wrong with the query though.
|
|
|
Re: SQL [message #619998 is a reply to message #619996] |
Sun, 27 July 2014 08:08 |
ORAGENASHOK
Messages: 240 Registered: June 2006 Location: Chennai
|
Senior Member |
|
|
yes dont have much difference
i can see that he changed mm to mi and to_char to to_date
but i have tried with both
when i change to_date to to_char
am getting
ORA-01722 invalid number
[Updated on: Sun, 27 July 2014 08:08] Report message to a moderator
|
|
|
|
|
|
|
Re: SQL [message #620005 is a reply to message #620004] |
Sun, 27 July 2014 09:39 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
Hope you also understood what Michel pointed out. Your between condition is nothing but "=" condition logically unless you have an interval.
Just a suggestion, from next time please show your session details using copy paste from SQL*Plus. It will have lot of error details for a quick turnaround.
And thanks for the feedback.
[Updated on: Sun, 27 July 2014 10:08] Report message to a moderator
|
|
|