I have created a query that gives me a count of all records by a particular person per day and ordered it by date by formatting a year month and day field and ordering by that progressively.
However I need the report to go one step further and count what how many records were created in the morning and how many in the afternoon etc.
I created a formatted time field and thought I could run 2 expressions against that (one expression to return a count of the Morning and the other to return the count of the Afternoon).
I am however failing miserably.
Any ideas?
Code:
SELECT tbl_AnnualServInsp.Date, tbl_AnnualServInsp.DBName, Format(Tbl_AnnualServInsp!Date,"dd/mm/yyyy") AS FormattedDate, Format(Tbl_AnnualServInsp!Date,"yyyy") AS GroupDate, Format(Tbl_AnnualServInsp!Date,"mm") AS FormattedMonth, Format(Tbl_AnnualServInsp!Date,"dd") AS FormattedDay, Format(tbl_AnnualServInsp!Date,"hh:nn:ss") AS AVTime, Format(tbl_NDTInspection!Date,"hh:nn:ss") AS NDTTime, Format(tbl_BCCInspection!Date,"hh:nn:ss") AS BCCTime, tbl_AnnualServInsp.OBJECTID, tbl_NDTInspection.OBJECTID, tbl_BCCInspection.OBJECTID INTO tbl_StreetlightInspectionFigures_stp1 IN 'W:\WorkOrd\Other Apps\SL_DB\StreetLightingDatabase-v2003-1_be.mdb'
FROM (tbl_AnnualServInsp LEFT JOIN tbl_BCCInspection ON tbl_AnnualServInsp.OBJECTID = tbl_BCCInspection.OBJECTID) INNER JOIN tbl_NDTInspection ON tbl_AnnualServInsp.OBJECTID = tbl_NDTInspection.OBJECTID
GROUP BY tbl_AnnualServInsp.Date, tbl_AnnualServInsp.DBName, Format(Tbl_AnnualServInsp!Date,"dd/mm/yyyy"), Format(Tbl_AnnualServInsp!Date,"yyyy"), Format(Tbl_AnnualServInsp!Date,"mm"), Format(Tbl_AnnualServInsp!Date,"dd"), Format(tbl_AnnualServInsp!Date,"hh:nn:ss"), Format(tbl_NDTInspection!Date,"hh:nn:ss"), Format(tbl_BCCInspection!Date,"hh:nn:ss"), tbl_AnnualServInsp.OBJECTID, tbl_NDTInspection.OBJECTID, tbl_BCCInspection.OBJECTID
HAVING (((tbl_AnnualServInsp.Date) Between [Forms]![frm_DailyFiguresbyInspector]![datefrom] And [Forms]![frm_DailyFiguresbyInspector]![dateto] & " 23:59:59"))
ORDER BY tbl_AnnualServInsp.DBName, Format(Tbl_AnnualServInsp!Date,"yyyy"), Format(Tbl_AnnualServInsp!Date,"mm"), Format(Tbl_AnnualServInsp!Date,"dd");
However I need the report to go one step further and count what how many records were created in the morning and how many in the afternoon etc.
I created a formatted time field and thought I could run 2 expressions against that (one expression to return a count of the Morning and the other to return the count of the Afternoon).
I am however failing miserably.
Any ideas?