illuzian
asked on
MySQL Select * from TABLE Between DATE RANGE?
Hey Guys,
I would like to know how to structure and SQL query to query between months ranges
Something along the lines of:
SELECT * FROM table WHERE datetime BETWEEN xx/xx/xx AND xx/xx/xx
We have a table with the following date field entry named datetime:
20090208175726478
Which I am assuming is an entry for 2009 02 08 TIME SECONDS or something along those lines
I have read the MySQL Reference on "date" but couldn't make much sense of it - SQL isn't my strong point.
Thanks in advance.
I would like to know how to structure and SQL query to query between months ranges
Something along the lines of:
SELECT * FROM table WHERE datetime BETWEEN xx/xx/xx AND xx/xx/xx
We have a table with the following date field entry named datetime:
20090208175726478
Which I am assuming is an entry for 2009 02 08 TIME SECONDS or something along those lines
I have read the MySQL Reference on "date" but couldn't make much sense of it - SQL isn't my strong point.
Thanks in advance.
ASKER
Okay cheers for the reply but we are using mysql 3.23 so it looks like this is not an options
I have put together this query but it only works if I specify
= 'xxxx-xx-xx'
and not the between as shown bellow any ideas?
I have put together this query but it only works if I specify
= 'xxxx-xx-xx'
and not the between as shown bellow any ideas?
select * from saled where date_add(concat(SUBSTRING(`DATETIME` FROM 1 FOR 4),'-',SUBSTRING(`DATETIME` FROM 5 FOR 2),'-',SUBSTRING(`DATETIME` FROM 7 FOR 2)), interval 0 day) between '2008-03-01' and '2008-06-01';
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Excellent answer for the query, I should of specified the version in the initial post as STR_TO_DATE was not available.
Open in new window