English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Initial dd/mm/yyyy was a varchar(100) format,
I need to convert it into database format which is yyyy-mm-dd
Pl. help

2007-04-03 15:38:48 · 3 answers · asked by athleticos78 1 in Computers & Internet Programming & Design

I asked and I answered.
The solution is
update aaa set a = STR_TO_DATE(replace(a, '/','.'),GET_FORMAT(DATE,'USA'));
#where a is the field and aaa is the table

2007-04-03 15:52:31 · update #1

3 answers

STR_TO_DATE(a, '%d/%m/%Y')

should work as well, and will be a little bit faster.

(in mysql 5.0 at least.)

2007-04-03 16:37:49 · answer #1 · answered by Vegan 7 · 0 0

hi! acturally i don't know how to convert dd/mm/yyyy to yyyy-mm-dd format in MySQL. But i do know how to convert it if you wanna the specified format date type data to be displayed on a web page. What is it? I would choose Jscript. First off, convert the date type data to string(if it's date type, surely you can skip this step since your date data is string) and then using Split method of Jscript to split dd/mm/yyyy into 3 parts and store them in an array. Then re-organize them and output them on web page. Example:

hope it helps!

2007-04-03 16:03:11 · answer #2 · answered by 维财(Weitsye Chung) 2 · 0 0

Your best bet is to peruse the documentation at http://www.mysql.org/ .

2007-04-03 15:43:41 · answer #3 · answered by Anonymous · 0 0

fedest.com, questions and answers