sql - mySQL query between two dates and two times -
I want to query a mySQL table to extract data between two dates and two times. I know how to do this for a "datetime" column using the "middle" column, but my columns are a "date" column and a "time" column.
From my range "Day 1" to 15:30 on day 1 + 1 day at 15:14
So far, I can get the following category (which works ):
Select time, intraday_values close to WHERE date = "2005-03-01" and the time between "15:30" and "23:59"
But I have to explicitly include 2 dates and twice I have tried the following but get an error:
SELECT time, date = "2005- 03-02 "and between time =" 15:30 "and date =" 2005- intraday_values close-to-03-02 "And time =" 15:14 "
Can someone help me in preparing questions correctly? Thank you very much
Not sure if your date field is indexed or not. If they are, then the "Concet" example others who have given them can not perform very well.
As an alternative, you can use a query in the form:
fromselect * to foo where (date & gt; lo_ command and date & lt; upper_date ) - Technically, this section is not required if they are one day different or (date = bottom_date and time> gt; = bottom_time) or (date = upper-date and time & lt; = overtime_time)
< / Pre>This is not beautiful, but it works and if they are in existence then the message to the date field is indexed Will allow you to use.
Your query
is SELECT time close to intraday_values, where (date & gt; "2005-03-01" and date is " 2005-03-02 ") or (date =" 2005-03-01 "and time> =" 15:30 ") or (date =" 2005-03-02 "and time
Comments
Post a Comment