Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everybody,

I need to capture the date from this string: "28/04/2011 16:38:04",

I need a function in sql language to make this o any sql-code.

Please give me an example.

Thanks in advance.

Leonardo Ayala.
Posted

1 solution

You what to use MySQL function STR_TO_DATE[^] there is some good example that can give you some good ideas.

SELECT STR_TO_DATE('01,5,2013','%d,%m,%Y');
--> DateTime output: 2013-05-01
 
Share this answer
 
v2
Comments
leocode7 2-May-11 14:34pm    
thanks, I improve your code:

select date(str_to_date( REPLACE( fecha,'/','-') ,'%d-%m-%Y')

thank you so much!
Kim Togo 2-May-11 16:09pm    
You are welcome.

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