Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 343735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:55:30+00:00 2026-05-12T10:55:30+00:00

I have a table containing reports and the date/time they were created. I’d like

  • 0

I have a table containing reports and the date/time they were created. I’d like to create a graph to tally the number of reports created during intervals of ten minutes between two time periods: 8:00AM-9:00AM and 1:00PM-2:00PM.

Here’s an example of a query I’d like to run:

SELECT
s.StudyStartDateTime AS "8:00 - 8:10",
s.StudyStartDateTime AS "8:10 - 8:20",
s.StudyStartDateTime AS "8:20 - 8:30",
s.StudyStartDateTime AS "8:30 - 8:40",
s.StudyStartDateTime AS "8:40 - 8:50",
s.StudyStartDateTime AS "8:50 - 9:00",
s.StudyStartDateTime AS "1:00 - 1:10",
s.StudyStartDateTime AS "1:10 - 1:20",
s.StudyStartDateTime AS "1:20 - 1:30",
s.StudyStartDateTime AS "1:30 - 1:40",
s.StudyStartDateTime AS "1:40 - 1:50",
s.StudyStartDateTime AS "1:50 - 2:00"
FROM
    dbo_Study_ViewX211_Rpt AS s
WHERE FORMAT("8:00 - 8:10", 'hh:mm:ss') BETWEEN "08:00:00" AND "08:09:59"
AND FORMAT("8:10 - 8:20", 'hh:mm:ss') BETWEEN "08:10:00" AND "08:19:59"
AND FORMAT("8:20 - 8:30", 'hh:mm:ss') BETWEEN "08:20:00" AND "08:29:59"
AND FORMAT("8:30 - 8:40", 'hh:mm:ss') BETWEEN "08:30:00" AND "08:39:59"
AND FORMAT("8:40 - 8:50", 'hh:mm:ss') BETWEEN "08:40:00" AND "08:49:59"
AND FORMAT("8:50 - 9:00", 'hh:mm:ss') BETWEEN "08:50:00" AND "08:59:59"
AND FORMAT("1:00 - 1:10", 'hh:mm:ss') BETWEEN "01:00:00" AND "01:09:59"
AND FORMAT("1:10 - 1:20", 'hh:mm:ss') BETWEEN "01:10:00" AND "01:19:59"
AND FORMAT("1:20 - 1:30", 'hh:mm:ss') BETWEEN "01:20:00" AND "01:29:59"
AND FORMAT("1:30 - 1:40", 'hh:mm:ss') BETWEEN "01:30:00" AND "01:39:59"
AND FORMAT("1:40 - 1:50", 'hh:mm:ss') BETWEEN "01:40:00" AND "01:49:59"
AND FORMAT("1:50 - 2:00", 'hh:mm:ss') BETWEEN "01:50:00" AND "01:59:59"

Unfortunately, it seems that Access isn’t able to tell that the field I’d like to format within the FORMAT function refers to the field of the same name in the query. In the above case, I assume this is because Access is treating this as a string literal. However, this doesn’t work, either:

SELECT
    s.StudyStartDateTime AS first
FROM
    dbo_Study_ViewX211_Rpt AS s
WHERE FORMAT(first, 'hh:mm:ss') BETWEEN "08:00:00" AND "08:09:59"

Access is prompting me for the value for ‘first’.

I feel like I’m going about this the wrong way to begin with. Can anyone point me in the right direction?

More info: I’m using the Jet engine through ODBC, but the data is actually stored in SQL Server 2005, so if necessary I suppose I could write a pass-through query. Ideally, however, I’d like it to work in Access.

EDIT:

To be clear, the following DOES work:

SELECT s.StudyStartDateTime AS first
FROM dbo_Study_ViewX211_Rpt AS s
WHERE FORMAT(StudyStartDateTime,'hh:mm:ss') Between "08:00:00" And "08:09:59";

This, however, doesn’t allow me to select the same field multiple times under multiple conditions.

The first example at http://office.microsoft.com/en-us/access/HA012288391033.aspx#examples suggests that wrapping the alias of the field in square braces is the correct way to reference a record source, but the following still results in a prompt for the value of ‘first’:

SELECT s.StudyStartDateTime AS first
FROM dbo_Study_ViewX211_Rpt AS s
WHERE FORMAT([first],'hh:mm:ss') Between "08:00:00" And "08:09:59";

Edit II:

An example of the contents of StudyStartDateTime of a few records:

29/11/2007 8:06:00 AM
30/11/2007 8:09:01 AM
05/12/2007 8:06:51 AM
06/12/2007 8:07:21 AM

Access sees this field as a “Date/Time” datatype.

My end goal is to graph the tally for each interval. I think the easiest way of doing this would be to simply select each date/time as a different alias. For instance:

8:00-8:10   8:10-8:20   8:20:8:30   ...
=======================================
8:01        
8:03
            8:15
                        8:23
                        8:28
                        8:28
...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:55:31+00:00Added an answer on May 12, 2026 at 10:55 am

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table containing records of the date and time each product was
In my table I have a varchar column called date containing string representations of
I have a table containing prices for a lot of different things in a
I have a table containing the runtimes for generators on different sites, and I
I have a table containing hundreds of entries and I am trying to delete
I have a table containing cells with text of various lengths. It is essential
I have a MySQL table containing domain names: +----+---------------+ | id | domain |
I have the following table containing the winning numbers of 6/49 lottery. +-----+------------+----+----+----+----+----+----+-------+ |
Say I have at database table containing information about a news article in each
We have a SQL Server table containing Company Name, Address, and Contact name (among

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.