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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:21:13+00:00 2026-06-05T15:21:13+00:00

SELECT Id,Date,Name FROM people WHERE DATEPART(hh,Date) >= 7 AND DATEPART(hh,Date) <= 8 Order by

  • 0
SELECT Id,Date,Name 
FROM people 
WHERE DATEPART(hh,Date) >= 7 
AND DATEPART(hh,Date) <= 8 
Order by DATEPART(ww,Date);

My database is SQL Server, and the thing is that “Date” are stored as a string type. If I execute that query it does not order properly.

What I want to do is, get each day’s value for between 7am and 8 am. For example, I want to get 14th of June records for between 7am and 8am, samething for 15th of june and so on….

  • 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-05T15:21:14+00:00Added an answer on June 5, 2026 at 3:21 pm

    First that all you (we) should know how it is stored in the DB. To parse the “varchar date” to a datetime.

    Let suppose we have the Date varchar storaged like mm/dd/yyyy
    so You should use a SELECT convert(datetime, THEDATECOLUMN, 101) -- mm/dd/yyyy

    You can take a look to more types of convert varchar to datetime here

    Ok, in the understanding that you have to convert first the varchar to date time and in this example using the mm/dd/yyyy we should write the query like this way.

    SELECT Id,Date,Name 
    FROM people 
    WHERE DATEPART(hh,convert(datetime, DATE, 101) ) >= 7 
    AND DATEPART(hh,convert(datetime, DATE, 101) )  <= 8 
    Order by convert(datetime, DATE, 101);
    

    Depending of how it is storaged, you should change the type of conversion listed in the related link

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

Sidebar

Related Questions

I have the following sql query : SELECT DATE(procedures.start) date, name, COUNT(procedure_types.id) count FROM
I have following SQL statementL: select DATE(bla), count(*) from tableA group by DATE(bla) UNION
SELECT (SELECT date FROM forums WHERE topic_id=f.id OR id=f.id ORDER BY id DESC LIMIT
select m.*, c.NAME as CORP_NAME from MAIL_LOG as m, CORP as c where m.SEND_DATE
string queryStr = select max(patient_history_date_bio) + as med_date, medication_name from biological where + (patient_id
My Query SELECT DATE, SEC_TO_TIME( SUM( TIME_TO_SEC( `total_hours` ) ) ) AS total FROM
I have an object in core data that has 2 fields: Name and Date.
I have a table named People in the following format: Date | Name .
SELECT a.[Evaluation Number], a.[CSO Name], a.service , a.[Date of call], a.[Name of Monitor] ,
Using SQL Server 2000 Having Two Tables Table1 Date ID 20090101 001 20090102 001

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.