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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:30:02+00:00 2026-06-07T20:30:02+00:00

There is a table which shows employee’s daily program. SELECT COUNT(*) AS TotalDay FROM

  • 0

There is a table which shows employee’s daily program.

SELECT COUNT(*) AS TotalDay FROM [User]
    INNER JOIN [x] ON [x].UserID = [User].ID  
WHERE       
        StartTime BETWEEN '20120611' AND '20120618' AND UserID = 20
GROUP BY [User].ID, [User].Name
ORDER BY Name

it return 7 records. because in one day, one user ( UserID) can go two different places.

For example,
This user went A place from 20120611 08:30:00 to 20120611 13:30:00
and went B place from 20120611 14:00:00 to 20120611 19:00:00

and this return 2 records when I use below query.

SELECT COUNT(*) AS TotalDay FROM [User]
     INNER JOIN [x] ON [x].UserID = [User].ID  
WHERE       
        StartTime = '20120611' AND UserID = 20
GROUP BY [User].ID, [User].Name
ORDER BY Name

But I want to get one record because that operations were in one day.

So how can I get it?

I use MSSQL. StartTime is datetime in sql.

  • 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-07T20:30:03+00:00Added an answer on June 7, 2026 at 8:30 pm

    Try following in your where clause:

    DATEADD(DD, DATEDIFF(DD, 0, STARTTIME), 0)  BETWEEN DATEADD(DD, DATEDIFF(DD, 0, <DATE_TIME_PARAMETER>), 0) AND DATEADD(DD, DATEDIFF(DD, 0, <DATE_TIME_PARAMETER>), 0)
    

    You will also need to group the results by above mentioned date part.

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

Sidebar

Related Questions

I have a database in which there is a user table & how many
Is there any info table/matrix which shows the attributes of char, varchar, text, real,
There is a column (REC_CREATE_TIMESTAMP) in a table which shows date in format YY-MM-DD.
I have a user table from which I want all values, so I have
In our database there is a table which is created with ANSI_NULLS OFF .
I am newbie to hibernate. If there is a table which has a composite
Suppose there is a table A which has a column AccessRights which is multivalued(
I need to implement the following: There is a table A which is supposed
I have a dynamically created table which in the last <td> there is a
I have a table in which there are two columns : 1. import type,

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.