hvilke format er din dato i ??
demo tabel jeg havde liggende
CREATE TABLE `tbl_users` (
`id` int(11) NOT NULL,
`firstname` varchar(255) COLLATE utf8_danish_ci NOT NULL,
`lastname` varchar(255) COLLATE utf8_danish_ci NOT NULL,
`postnummer` varchar(4) COLLATE utf8_danish_ci NOT NULL,
`lande_id` int(1) NOT NULL,
`username` varchar(255) COLLATE utf8_danish_ci NOT NULL,
`password` varchar(255) COLLATE utf8_danish_ci NOT NULL,
`last_logon` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_danish_ci;
INSERT INTO `tbl_users` (`id`, `firstname`, `lastname`, `postnummer`, `lande_id`, `username`, `password`, `last_logon`) VALUES
(1, 'rip', 'andemad', '4000', 1, '1', '1234', '2017-06-13 00:00:00'),
(3, 'rap', 'and', '2500', 1, '3', '1234', '2017-06-04 00:00:00'),
(4, 'rup', 'and', '8000', 1, '4', '1234', '2017-06-11 00:00:00'),
(5, 'mickey', 'mouse', '4000', 1, '5', '1234', '2017-06-05 00:00:00'),
(7, 'bimmer', 'vildmand', '4000', 1, '7', '1234', '0000-00-00 00:00:00'),
(8, 'jule', 'mand', '2412', 2, '8', '1234', '0000-00-00 00:00:00');
ALTER TABLE `tbl_users`
ADD PRIMARY KEY (`id`),
ADD KEY `idx_username_password` (`username`,`password`),
ADD KEY `idx_lastname` (`lastname`);
ALTER TABLE `tbl_users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
lig mærke til last_logon` datetime
sql
SELECT * FROM tbl_users WHERE DATE(last_logon) > DATE(DATE_SUB( NOW(), INTERVAL 7 DAY) )
lig mærke til > og ikke <
output
id,firstname,lastname,postnummer,lande_id,username,password,last_logon
1,rip,andemad,4000,1,1,1234,2017-06-13 00:00:00
4,rup,and,8000,1,4,1234,2017-06-11 00:00:00
havde du valgt denne sql
SELECT * FROM tbl_users WHERE DATE(last_logon) < DATE(DATE_SUB( NOW(), INTERVAL 7 DAY) )
dvs vendt > om havde du fået de 4 andre ud
så vi skal bruge en demo tabel, med demo dat og forvendtet output