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

  • Home
  • SEARCH
  • 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 6550779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:15:27+00:00 2026-05-25T12:15:27+00:00

I have a table with the fields: resourceID , work_date , stringValue I’m trying

  • 0

I have a table with the fields: resourceID,work_date,stringValue

I’m trying to build an Access query that will show a count of how many different resourceID numbers with a given stringValue occur in each week over a given date range. Using partition() seems to be the simplest approach, however, when I use the following query:

select partition([work_date],#6/6/2011#,#9/4/2011#,7),stringValue,
count(resourceID) from 
(select distinct resourceID,work_date,stringValue from myTable) as subQuery
group by partition([work_date],#6/6/2011#,#9/4/2011#,7), stringValue

then I have two problems:

-My dates end up formatted as integers, e.g.:

:40699
40700:40706
40784:40790

whereas I want them to appear as, e.g., 6/6/2011:6/12/2011 (I also don’t want the :40699 value)

–resourceID gets counted more than once per week if it appears on more than one weekday; I just want it to be counted once for each stringValue if it appears at all that week. I thought the distinct qualifier would accomplish this but it didn’t.

EDIT: I’ve solved the excess resourceID count by putting the partition in a subquery as follows:

select datePartition,stringValue,count(ID)
from (select partition() as datePartition, stringValue, ID
from (select distinct stringvalue,ID,work_date))
group by datePartition,stringvalue

and then pulling count(ID) from that subquery. Still can’t figure out the date formatting, though.

  • 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-25T12:15:28+00:00Added an answer on May 25, 2026 at 12:15 pm

    To get rid of the range which ends with 40699, try revising the subquery piece. Add a WHERE condition to limit rows to work_date values >= #6/6/2011#

    SELECT DISTINCT resourceID, work_date, stringValue
    FROM myTable
    WHERE work_date >= #6/6/2011#;
    

    I’m not clear about your description regarding the duplicate rows from the SELECT DISTINCT. One possibility could be that at least some of your work_date values contain different time values from the same date. So two rows with the same resourceID and stringValue, but work_date values of #6/6/2011 01:00 AM# and #6/6/2011 02:00 AM#, would legitimately qualify as distinct.

    If that’s not the explanation, clarify your question by showing us a smallish set of data from myTable, and the resultset of that data which illustrates how you want the data evaluated.

    AFAICT, the issue about Partition() presenting your date ranges as whole numbers is unavoidable. According to the help topic, Partition() expects whole numbers for its parameters. Apparently it’s willing to accept your Date/Time values by casting them to whole numbers. But it’s not willing/able to transform them back to date strings. You would have to transform them back yourself. A user-defined function could do it when called from a query.

    Public Function WholeNumRange2Date(ByVal pRange As String)
        Const cstrFmt As String = "m/d/yyyy"
        Dim varPieces As Variant
        varPieces = Split(pRange, ":")
        WholeNumRange2Date = Format(CDate(varPieces(0)), cstrFmt) & _
            ":" & Format(CDate(varPieces(1)), cstrFmt)
    End Function
    

    An example from the Immediate Window which uses that function …

    ? WholeNumRange2Date("40700:40706")
    6/6/2011:6/12/2011
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table with some fields that the value will be 1 0. This
I have a table in MySQL that has 3 fields and I want to
I have a table that defines the possible categories in my website - fields
I have a table with three fields, FirstName, LastName and Email. Here's some dummy
I have a table with 3 fields: ID (not unique, not primary key) timestamp
I have a table with three fields, User , City and Country , where
I have a table T with fields id, parentid , name. i make relationship
I have a table of 2 fields. Word and timestamp. Then i have this
I have a table with 3 fields: color, fruit, date. I can pick 1
If I have a table Orders with fields CustomerID , OrderID and OrderDate ,

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.