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 8555701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:11:03+00:00 2026-06-11T15:11:03+00:00

I need to get all the CustomerOrders created within a time span, group them

  • 0

I need to get all the CustomerOrders created within a time span, group them by day (regardless of what time during that day) and then also include the count of CustomerOrders for each day. My ChartDateCount class has two properties – Date and Count.

So, here is some example SQL data:

OrderID     Created
1           1/1/2012 04:30:12  
2           1/1/2012 05:15:29  
3           1/1/2012 07:09:45  
4           1/3/2012 01:12:21  
5           1/4/2012 06:33:58  
6           1/4/2012 08:30:26  
7           1/5/2012 10:17:41  
8           1/5/2012 11:30:43  
9           1/6/2012 01:11:11  

And my output should be:

Date         Count
1/1/2012     3
1/3/2012     1
1/4/2012     2
1/5/2012     2
1/6/2012     1

This is what I have so far.

Dim chartData as List(Of ChartDateCount) = _
         ( _
            From co In dc.CustomerOrders _
            Where co.Created >= fromDate _
            And co.Created <= toDate _
            Select New ChartDateCount With {.Date = ???, .Count = ???} _
         ).ToList()

I kind of got close with this one but I couldn’t get Date to populate:

From co In CustomerOrders _
Where co.Created >= "1/1/2012" And co.Created <= "1/7/2012" _
Group co By co.Created.Value.Date Into g = Group _
        Select New ChartDateCount With {.Date = ????, .Count = g.Count()}

UPDATE

This is exactly what I want to do (see below) in theory but I get an error this error: The query operator 'ElementAtOrDefault' is not supported.

From co In CustomerOrders _
Where co.Created >= "1/1/2012" And co.Created <= "1/7/2012" _
Group co By co.Created.Value.Date Into g = Group _
        Select New ChartDateCount With {.Date = g(0).Created.Value.Date, .Count = g.Count()}
  • 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-06-11T15:11:05+00:00Added an answer on June 11, 2026 at 3:11 pm

    I figured out a way but if anyone has a more efficient way of going about this, I will certainly give you credit instead…

    Dim chartData as List(Of ChartDateCount) = _
        (
            From co In dc.CustomerOrders _
                    Where co.Created > fromDate _
                       And co.Created < toDate _
                Group By co.Created.Value.Date Into g = Group _
                       Select New ChartNameValue With _
                       {
                          .Date = (From co2 As CustomerOrder In g).Take(1).Single().Created.Value.Date, _
                          .Count = g.Count()
                       }
         ).ToList()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a Facebook Application that I need to get all the information
I need to get all rows that were affected by a bulk delete like
I need to get all those files under D:\dic and loop over them to
I need to get all rows tha are valid, ValidDate is column that shows
I need to get all of the users in my user table and then
I need to get all images that begin with t_ using glob. What pattern
I need to get all of the IP addresses contained in within a subnet
I need to get all the files in a folder that match a certain
Using C#, I need to get all Firefox bookmarks for importing them into our
I need to get all the objects in my application that implement a given

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.