Having difficulties when converting a year to unix time in MySQL.
This is my table:
CREATE TABLE `person` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`born_date` int(45) DEFAULT NULL,
`unix_born_date` varchar(100) DEFAULT NULL,
`death_date` varchar(45) DEFAULT NULL,
`unix_death_date` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8;
In the field born_date I have years, like «1864». I want to convert them to Unix Time in a query, something like:
SELECT id, UNIX_TIMESTAMP(STR_TO_DATE(born_date, '%Y')) AS Unixtime
FROM person
But it returns 0…
Does anyone has an idea what to do to convert the year to Unix Time?
N.