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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:33:01+00:00 2026-06-03T07:33:01+00:00

I want to make a query which returns me some values between two dates

  • 0

I want to make a query which returns me some values between two dates and two times…

The DATE and TIME values are in different columns, DATE is called FECHA and TIME is called HORAIN

I have 4 possible values with just a DATE query:

Value 1 has Date 2012-05-07 time 02:45:00
Value 2 has Date 2012-05-07 time 12:00:00
Value 3 has Date 2012-05-08 time 04:35:00
Value 4 has Date 2012-05-08 time 07:30:00

What I want to get, is the results from 07:00:00 to 23:59:59 from the first day, and values from 00:00:00 to 06:59:59 from the second day (so an interval from 07 AM to 06:59 AM)

This is my query, which is returning NO VALUES… It must return me VALUE 2 and VALUE 3, because it matches my desired requirements

SELECT * FROM mytable
WHERE
(DATE(fecha)>='2012-05-07' AND TIME(horain)>='07:00:00')
AND
(DATE(fecha)<='2012-05-08' AND TIME(horain)<='06:59:59');

What am I doing wrong? 🙁

  • 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-03T07:33:03+00:00Added an answer on June 3, 2026 at 7:33 am

    You can fetch result using Concat(). It concatenating two fields value.so You can concatenate fecha with horain field value and then search for results like given below .

    SELECT *   FROM `mytable` WHERE (Concat(`fecha`, ' ', `horain`, '') <= '2012-05-08 06:59:59') AND (Concat(`fecha`, ' ', `horain`, '') >= '2012-05-07 07:00:00')
    

    Concat() function take 4 parameter.

    1. Value1
    2. String from which concatenate value1 to value2
    3. Value2
    4. String want to concatenate in last

    Hopefully it will be helpful for you

    thanks.

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

Sidebar

Related Questions

I am using mssql and I want to make a query that returns a
I want make a bash script which returns the position of an element from
I want to make a query using which I can check that URL which
I'm trying to make a SELECT query which only returns rows when a column
I want to make a query to list cats that took longer than average
I have 3 tables, and I want to make a query for a search
I want to make a CAML query semi-smart - in that I can give
I want to make this kind of query: create procedure something @name varchar(13) as
I will make this quick and simple I have a query and I want
Let's say I want make some of my sources publicly available via my blog

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.