M
madt
Guest
Hello,
I'm trying to build a SQL statement with which I can group the table entries according to month and year, and not according to the whole date. Eg, all entries entered in September 2004 must be in one group. At the moment I can only get them to group by the whole date, thus entries entered on 13 September 2004 will be grouped, but entries on 13 and 24 September will not be grouped together.
I'm trying to build links for each month of a year, so that users can click on a link and view all the entries for that specific month and year.
Am I being clear here? I'm getting more and more confused....
I'm using ASP with an Access database.
This is the SQL code:
SELECT format(arcDate,'mmmm yyyy') AS fdate, format(arcDate,'dd/mm/yyyy') AS ndate
FROM archive
WHERE arcCatagory = 2
GROUP BY arcDate
ORDER BY arcDate DESC
which groups by the whole date.
fdate is for the links, and ndate is for the querystring value that gets passed when a link is clicked.
arcDate is the date the entry got entered into the database.
Now when I try to group by only the month and year:
SELECT format(arcDate,'mmmm yyyy') AS fdate, format(arcDate,'dd/mm/yyyy') AS ndate
FROM archive
WHERE arcCatagory = 2
GROUP BY format(arcDate,'mmmm yyyy')
ORDER BY arcDate DESC
I get this lovely error:
[Microsoft][ODBC Microsoft Access Driver] You tried to execute a query that does not include the specified expression 'format(arcDate,'dd/mm/yyyy')' as part of an aggregate function.
Helep? What am I doing wrong?
Helep Helep!
I'm trying to build a SQL statement with which I can group the table entries according to month and year, and not according to the whole date. Eg, all entries entered in September 2004 must be in one group. At the moment I can only get them to group by the whole date, thus entries entered on 13 September 2004 will be grouped, but entries on 13 and 24 September will not be grouped together.
I'm trying to build links for each month of a year, so that users can click on a link and view all the entries for that specific month and year.
Am I being clear here? I'm getting more and more confused....
I'm using ASP with an Access database.
This is the SQL code:
SELECT format(arcDate,'mmmm yyyy') AS fdate, format(arcDate,'dd/mm/yyyy') AS ndate
FROM archive
WHERE arcCatagory = 2
GROUP BY arcDate
ORDER BY arcDate DESC
which groups by the whole date.
fdate is for the links, and ndate is for the querystring value that gets passed when a link is clicked.
arcDate is the date the entry got entered into the database.
Now when I try to group by only the month and year:
SELECT format(arcDate,'mmmm yyyy') AS fdate, format(arcDate,'dd/mm/yyyy') AS ndate
FROM archive
WHERE arcCatagory = 2
GROUP BY format(arcDate,'mmmm yyyy')
ORDER BY arcDate DESC
I get this lovely error:
[Microsoft][ODBC Microsoft Access Driver] You tried to execute a query that does not include the specified expression 'format(arcDate,'dd/mm/yyyy')' as part of an aggregate function.
Helep? What am I doing wrong?
Helep Helep!