I have all my data stamped with a field- dated which is in the format Y-m-d H:i- i would like to cast this field using mysql to represent the hour of the day so- 2011-11-21 15:28:05 would become 15- i have been reading the docs but it doesnt state whether or not you can specify a format
is this possible?
The idea is, I can count how many rows are stamped for each hour then display this in a graph.
this has been my working so far
SELECT CAST(dated AS TIME) FROM `posts` WHERE CAST(dated AS DATE) = CAST('".$start_date."' as DATE) AND type = '' ORDER by dated ASC;
Use date_format:
Or to get just the hour, regardless of day: