[SOLVED] date intervals

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
irealms
Forum Contributor
Posts: 215
Joined: Mon Apr 28, 2003 7:10 am
Location: Leeds

date intervals

Post by irealms »

i'm having problems getting this to work

SELECT * FROM orders WHERE DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= dateadded AND status!='Quote'

keep getting errors and despite trying the manual i can't seem to get it working. Any ideas?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What's the error?

Mac
User avatar
irealms
Forum Contributor
Posts: 215
Joined: Mon Apr 28, 2003 7:10 am
Location: Leeds

Post by irealms »

unexpected TL_NUMBER, T_VARIABLE or $
User avatar
irealms
Forum Contributor
Posts: 215
Joined: Mon Apr 28, 2003 7:10 am
Location: Leeds

Post by irealms »

erm i had a varible $7orders, it didn't like the 7 :)
User avatar
irealms
Forum Contributor
Posts: 215
Joined: Mon Apr 28, 2003 7:10 am
Location: Leeds

Post by irealms »

the query now seems to not be drawing from 7 days, i have 5 orders in database from october, 4 from 14th and one from 4th and it's counting 5 as in the last 7 days, though the one from the 4th shouldn't be counted.
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

can you post your code please?
User avatar
irealms
Forum Contributor
Posts: 215
Joined: Mon Apr 28, 2003 7:10 am
Location: Leeds

Post by irealms »

$weekorders = "SELECT * FROM orders WHERE DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= dateadded AND status!='Quote'";
$weekordersq = mysql_query($weekorders, $db_conn) or die("Query $weekordersq Failed".mysql_error());
User avatar
irealms
Forum Contributor
Posts: 215
Joined: Mon Apr 28, 2003 7:10 am
Location: Leeds

Post by irealms »

hmm don't know what i did but it's working now i think :)
Post Reply