I'm trying to calculate how many business days have passed since a given date
CREATE TABLE `TestTable` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`user` varchar(255) DEFAULT NULL,
`date` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
And this is my query, but I got stuck
SELECT
SUM(5 * (DATEDIFF(NOW(), date) DIV 7) + MID('0123444401233334012222340111123400001234000123440',
7 * WEEKDAY(date) + WEEKDAY(date) + 1,
1) + ((TIMESTAMPDIFF(SECOND,
NOW(),
date) / 86400) - (DATEDIFF(NOW(), date)))) AS Business_Days, user, date
FROM
MyDB.TestTable
If someone can help me telling me what I'm doing wrong.