Click here to Skip to main content
15,509,458 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

in my oracle table I have a column called :
processdate
datatype date.

Process date value in table is :
6/5/2018


trying to run the below query getting exception .

SELECT to_date(substr(:processdate, 1,10), 'mm/dd/YYYY') FROM table


if I enter processdate :
6/5/2018
it was throwing exception like
A-01843: not a valid month


please guide me what is wrong with this query.

Thanks inadvance.

What I have tried:

<pre>SELECT to_date(substr(:processdate, 1,10), 'mm/dd/YYYY') FROM table


if I enter processdate :
6/5/2018
it was throwing exception like
A-01843: not a valid month
Posted
Updated 6-Jun-18 23:34pm
Comments
Richard Deeming 6-Jun-18 16:25pm    
Shouldn't that be 'M/D/YYYY', since you're not using leading zeros on the month and day numbers?

And the fact that you're using TO_DATE would suggest that your column's datatype is NOT date.
sai.2012 6-Jun-18 16:33pm    
HI Richard,

Thx for the reply , but in database Process date datatype is date only.

I am not using leading zero's on the month and day numbers.

1 solution

Assuming that a processdate field is a datetime data type and you want to reject/remove time part, you have to use TRUNC[^] function.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900