Click here to Skip to main content
15,905,874 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Below is the piece of the code (simplified) for updating a table w/ a DataTime value, where the field:
CREATED_DATE
is DATE in its DataType
SQL
Update  myTable SET CREATED_DATE=5/8/2017 9:17:07 AM WHERE E_ID = 9270002

I tried this in SQL Developer, but not successful. What is wrong in my code? Thanks.

What I have tried:

Tried on SQL Developer and also in .Net debugging
Posted
Updated 8-May-17 10:21am

You need to put the values in quotes, otherwise it thinks you are trying to divide numbers.
SQL
SET CREATED_DATE='5/8/2017 9:17:07 AM'
 
Share this answer
 
Comments
Maciej Los 8-May-17 16:21pm    
5ed!
s yu 9-May-17 7:20am    
Thank. But need to do like that one below:
SET CREATED_DATE='8-MAY-2017 9:17:07 AM'
Try
SQL
Update myTable SET CREATED_DATE='2017-05-08 09:17:07' WHERE E_ID=9270002
Note that the date cannot be interpreted as anything other than 8th May 2017. I also think if you are going to use "AM" in the time there should be no space. Personally I think 24hr format is best.

For more information see Understanding Oracle SQL Date Format Made Easy[^]

[UPDATE]OP is reporting an error.
Try '2017-MAY-08 09:17:07" instead. Or try
SQL
TO_DATE(
    'May 8, 2017, 09:17 A.M.',
    'Month dd, YYYY, HH:MI A.M.',
     'NLS_DATE_LANGUAGE = American')
Reference:TO_DATE[^]
Otherwise look to the link I provided for more ideas
 
Share this answer
 
v2
Comments
CHill60 9-May-17 7:12am    
I've updated my solution with a couple of alternatives

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