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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:18:32+00:00 2026-06-06T15:18:32+00:00

I want to convert : select convert(nvarchar(16), TimeLog, 120) requestTime, count(Request) As noOfQueries from

  • 0

I want to convert :

select  convert(nvarchar(16), TimeLog, 120) requestTime,
        count(Request) As noOfQueries 
from    LogData 

where  TimeLog  between @StartDate and @EndDate

group by convert(nvarchar(16), TimeLog, 120) order by requestTime;

Here in the where clause the Timelog is between: 2012-06-21 and 2012-06-21 but I want it between 2012-06-21 00:00:00 and 2012-06-21 23:59:59

Hence I want to convert the @Satrtdate / @EndDate into above format so I would like to append 00:00:00 to @StartDate and 23:59:59 to @EndDate .

  • 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-06T15:18:35+00:00Added an answer on June 6, 2026 at 3:18 pm

    What you want is:

    SELECT 
      requestDate = CONVERT(CHAR(10), TimeLog, 120), 
      noOfQueries = COUNT(Request)
    WHERE TimeLog >= @StartDate 
    AND TimeLog < DATEADD(DAY, 1, @EndDate)
    GROUP BY CONVERT(CHAR(10), TimeLog, 120)
    ORDER BY CONVERT(CHAR(10), TimeLog, 120);
    

    The reason you don’t want to use BETWEEN is because its behavior will differ depending on the underlying data type. If it’s SMALLDATETIME, you will round up, and get data from the next day. If it’s DATETIME2, you could miss data between 23:59:59.0000000 and 23:59:59.9999999. And even if you know the data type now, it could change after you publish your query. Who’s going to go back and correct 23:59:59 to 23:59:00 or 23:59:59.9999999? With an open-ended range, selecting everything before the next day at midnight, you’ll never have to worry about it.

    Please give these two articles a read:

    • What do BETWEEN and the devil have in common?

    • Bad habits to kick : mis-handling date / range queries

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

Sidebar

Related Questions

for example, i want to convert this; $this->db->get('table'); to this; 'SELECT * FROM table'
In a SELECT statement I want to convert values to strings ie. SELECT TO_STRING(value).
I want to convert the following SQL Query to a SubSonic Query. SELECT [dbo].[tbl_Agency].[ParentCompanyID]
I want only Hr and Min in time format so i did select convert(varchar(20),GETDATE(),108)
I want to convert time to hh:mm from hh:mm:ss it comes from database (my
I Want convert bit type to Yes or No For Example: SELECT FirstName, LastName,
I want to convert the following subquery to use hibernate subquery: getCurrentSession().createQuery(from Employee where
I want to convert personArray to a JSON string, and send a request to
I want script to convert my table CREATE TABLE #TempTable ( Code nvarchar(5) primary
I want to convert a solution of <select /> box chaining I've already built

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.