I have a table with a varchar column called birthday
CREATE TABLE IF NOT EXISTS `test` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `birthday` varchar(30) COLLATE utf16_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci AUTO_INCREMENT=5 ;
INSERT INTO `test` (`id`, `birthday`) 
VALUES (1, '20041225'),
       (2, '2004-12-25'),
       (3, '19941225'),
       (4, '19941201');
I try to run this query:
SELECT str_to_date(birthday,"%Y%m%d") 
FROM `test` 
WHERE 1
But it always return rows with null values.
If I run the query:
SELECT str_to_date('20141225',"%Y%m%d") 
FROM `test` 
WHERE 1
It will return 2014-12-25
So what wrong with my query?
 
     
     
     
    