Hello,
I have done some research into this but was wondering if anyone could help.
I am running a SQL Query which returns the top 40 rows from a specific table. I’ll post this query below but I appreciate it might not mean a great deal.
SELECT top 40 Title, Description, DateCreated, Slug FROM be_Posts order by DateCreated DESC
This query returns a structure of information, but the column I am interested in is the DateCreated column. An example of this is below (the comma denotes a new row).
2010-12-14 08:30:00.000, 2010-12-14 08:13:00.000, 2010-12-14 07:49:00.000, 2010-12-14 07:19:00.000, 2010-12-13 16:01:00.000, 2010-12-12 18:33:00.000, 2010-12-09 17:44:00.000, 2010-12-06 17:45:00.000, 2010-12-06 11:09:00.000, 2010-12-04 16:53:00.000, 2010-12-03 20:57:00.000, 2010-12-02 14:16:00.000, 2010-12-02 13:31:00.000, 2010-12-02 12:21:00.000, 2010-12-02 11:30:00.000
The above information are dates and times in a particular format. The end result of this project would be to group each date, but then pull the other content from the remaining cells in the row.
To help visualise this:
14th December 2010
– 2010-12-14 08:30:00.000
– 2010-12-14 08:13:00.000
– 2010-12-14 07:49:00.000
– 2010-12-14 07:19:00.000
13th December 2010
– 2010-12-13 16:01:00.000
12th December 2010
– 2010-12-12 18:33:00.000
Of course, within each group the rows are ordered by time. For example, in the group above, for ‘14th December’ the times start with ‘07:19:00.000’ at the bottom and end with ‘08:30:00.000’ at the top. I am unaware which date/time format this is in or even if this is necessary to know.
I was thinking a foreach statement would be appropriate to order the rows into groups and from there by date. In English the statement would be: foreach row, order by date and, only AFTER, order by descending time.
I hope I have explained this well enough to merit support. I would be more than grateful to any replies offering advice.
Thank you,