I have a small self made gallery which im still working on it:
http://springbreak.enteratenorte.com
And the SQL structure is the following:
CREATE TABLE IF NOT EXISTS 'en_albums' (
'id' int(11) NOT NULL auto_increment,
'name' text,
'folder' text,
'description' text,
'hits' int(11) default NULL,
'datecreated' date default NULL,
PRIMARY KEY ('id')
) ENGINE=MyISAM AUTO_INCREMENT=372 DEFAULT CHARSET=latin1 AUTO_INCREMENT=372 ;
And I have around 300 albums, so I would to sort the most popular which is simple with this query:
SELECT * FROM en_albums ORDER BY hits DESC
But I would like to know how can I do the same thing, but only sort album not older than 6 month, or 1 month, or 1 year, this is a sample of the lines in my albums:
INSERT INTO 'en_albums'
('id', 'name', 'folder',
'description', 'hits', 'datecreated')
VALUES
(1, 'Friends Picture', 'en-fotosdeamigos',
'Pictures sent by our visitors', 1514, '2005-07-19');
Thanks for the help! 😀
Assuming you only want to get albums created within a time period you can use
This will only return items which have a datecreated greater than 6 months ago. You can change the
6andMONTHpart to be what you want. You can replaceMONTHwith any of the following: