Selecting Time ranges from Date Time fields in Access

可紊 提交于 2019-12-06 19:21:38

The problem you are having is because access doesn't reference fields by their aliases within the same query. Meaning you can't assign an alias in the select clause and use it in the where clause.

As for the first part of your question, you can try something like this

    SELECT 
        sum(iif(FORMAT(s.StudyStartDateTime,'hh:mm:ss') 
                BETWEEN "08:00:00" AND "08:09:59",1,0)) as "8:00 - 8:10",
        sum(iif(FORMAT(s.StudyStartDateTime,'hh:mm:ss') 
                BETWEEN "08:10:00" AND "08:19:59",1,0)) as "8:10 - 8:20",
        ...
    FROM dbo_Study_ViewX211_Rpt AS s

This will give you a tally for each 10 minute period.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!