Link to home
Start Free TrialLog in
Avatar of Peter Chan
Peter ChanFlag for Hong Kong

asked on

Problem to update

Hi,
Any advice to this error?
17:08:24	update package set sms_time = STR_TO_DATE('1/4/2015 15:30:00','%d/%m/%Y %h:%i:%s') where id = 640725
	0 row(s) affected, 1 warning(s): 1411 
Incorrect datetime value: '1/4/2015 15:30:00' for function str_to_time
 Rows matched: 1  
Changed: 0  
Warnings: 0	
0.000 sec
				

Open in new window

Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

What is the %i in the format of the time part?  I think that should be %m
Avatar of Peter Chan

ASKER

I got the same                        
17:53:15	update package set sms_time = STR_TO_DATE('1/4/2015 15:30:00','%d/%m/%Y %h:%m:%s') where id = 640725	0 row(s) affected, 1 warning(s): 1411 Incorrect datetime value: '1/4/2015 15:30:00' for function str_to_time Rows matched: 1  Changed: 0  Warnings: 0	0.000 sec

Open in new window

when using "m" instead.
SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Why can't use CONVERT function to convert string to date? The format in which you'd like to convert could be passed as last parameter.

http://www.techonthenet.com/sql_server/functions/convert.php
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial