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? 🙁
You can fetch result using
Concat(). It concatenating two fields value.so You can concatenatefechawithhorainfield value and then search for results like given below .Concat()function take 4 parameter.Value1String from which concatenate value1 to value2Value2String want to concatenate in lastHopefully it will be helpful for you
thanks.