Currently I can select by month and year
SELECT FROM db.table WHERE MONTH(datetimefield) = 4;
SELECT FROM db.table WHERE YEAR(datetimefield) = 4;
However, how would I select by hour or date? Hour more importantly.
SELECT BY HOUR? Datetime related
Moderator: General Moderators
feyd | Please use
Somehow I think I need to implement count and group by, any advice welcome!
feyd | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Okay so its
Day(), Month(), Year(), Hour()
Now I have a different question.
I want to get a count of how many users were created per day between an entered time period.
So far I have...
[syntax="sql"]SELECT * FROM db.`table` WHERE `created` > '$dateOne' AND `created` < '$dateTwo'feyd | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]You've already given yourself a pretty good advice - try itSmasher wrote: SELECT * FROM db.`table` WHERE `created` > '$dateOne' AND `created` < '$dateTwo'
Somehow I think I need to implement count and group by, any advice welcome!
There are 10 types of people in this world, those who understand binary and those who don't
Okay so I've got this
However its only returning days that have a count of over one, is there away to return EVERY day? I need a list which includes every day.
Thanks!
Code: Select all
"SELECT COUNT(`id`) as `No`, `created` FROM db.`table` WHERE `created` > '$dateOne' AND `created` < '$dateTwo' GROUP BY DATE(`created`) "However its only returning days that have a count of over one, is there away to return EVERY day? I need a list which includes every day.
Thanks!