Re: [PHP-DB] DATE_SUB Issues

2004-03-30 Thread Ricardo Lopes
the first time i saw this post i get confused, let me see if i understand.

you want the _CURRENT_ week stats 
OR
the stats from the last 7 days

if you want the first you cant use now

the reason why that script works was because it was monday :) 

  SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'), 
  WEEK(time_upload, 1) FROM TRAININGLOG WHERE DATE_SUB( NOW(),INTERVAL 7 
  DAY ) = time_upload GROUP BY time_upload LIMIT 1
- Original Message - 
From: Craig Hoffman [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 29, 2004 9:48 PM
Subject: Re: [PHP-DB] DATE_SUB Issues


 WooHoo!  I got it working!
 Basically what I did is I changed this  DATE_SUB( NOW(),INTERVAL 7 DAY 
 )  to DATE_SUB( NOW(),INTERVAL 1 DAY ) and it worked.  I am not 
 entirely sure why.  Anyone know?
 __
 Craig Hoffman - eClimb Media
 
 v: (847) 644 - 8914
 f: (847) 866 - 1946
 e: [EMAIL PROTECTED]
 w: www.eclimb.net
 _
 On Mar 29, 2004, at 10:56 AM, Craig Hoffman wrote:
 
  What is should doing is grabbing all entries of this week and return a 
  total.  Its returning the wrong results.
 
  SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'), 
  WEEK(time_upload, 1) FROM TRAININGLOG WHERE DATE_SUB( NOW(),INTERVAL 7 
  DAY ) = time_upload GROUP BY time_upload LIMIT 1
 
  = Results: (This is wrong)
  = Weekly Miles: (Week starts on Monday)  5.34
 
  Correct Results should be this:
  Weekly Miles:   30.5
  __
  Craig Hoffman - eClimb Media
 
  v: (847) 644 - 8914
  f: (847) 866 - 1946
  e: [EMAIL PROTECTED]
  w: www.eclimb.net
  _
  On Mar 29, 2004, at 10:29 AM, John W. Holmes wrote:
 
  From: Craig Hoffman [EMAIL PROTECTED]
  On Mar 29, 2004, at 10:06 AM, John W. Holmes wrote:
  From: Craig Hoffman [EMAIL PROTECTED]
 
  still no luck - any other suggestions?
 
  Please define no luck
 
  Yes of course.   Here is my new query.
 
SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'),
  WEEK(time_upload, '7') FROM TRAININGLOG WHERE DATE_SUB( 
  NOW(),INTERVAL
  7 DAY ) = time_upload GROUP BY time_upload LIMIT 1
 
  So how does it not work? What are you expecting? What is returned? Is 
  an
  error occuring or the wrong results or no results??
 
  ---John Holmes...
 
 
  -- 
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] DATE_SUB Issues

2004-03-30 Thread Ricardo Lopes
sorry, i press Control+Enter and i send the unfinished mail, here is the
continuation:

it worked because it was monday, probably today you arent happy.

try this sql, but i dont like the GROUP clause

SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'), WEEK(time_upload, 1)
FROM TRAININGLOG
WHERE (WEEK(NOW(), 1) = WEEK(time_upload, 1))
GROUP BY time_upload
LIMIT 1

- Original Message -
From: Craig Hoffman [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 29, 2004 9:48 PM
Subject: Re: [PHP-DB] DATE_SUB Issues


 WooHoo!  I got it working!
 Basically what I did is I changed this  DATE_SUB( NOW(),INTERVAL 7 DAY
 )  to DATE_SUB( NOW(),INTERVAL 1 DAY ) and it worked.  I am not
 entirely sure why.  Anyone know?
 __
 Craig Hoffman - eClimb Media

 v: (847) 644 - 8914
 f: (847) 866 - 1946
 e: [EMAIL PROTECTED]
 w: www.eclimb.net
 _
 On Mar 29, 2004, at 10:56 AM, Craig Hoffman wrote:

  What is should doing is grabbing all entries of this week and return a
  total.  Its returning the wrong results.
 
  SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'),
  WEEK(time_upload, 1) FROM TRAININGLOG WHERE DATE_SUB( NOW(),INTERVAL 7
  DAY ) = time_upload GROUP BY time_upload LIMIT 1
 
  = Results: (This is wrong)
  = Weekly Miles: (Week starts on Monday)  5.34
 
  Correct Results should be this:
  Weekly Miles:   30.5
  __
  Craig Hoffman - eClimb Media
 
  v: (847) 644 - 8914
  f: (847) 866 - 1946
  e: [EMAIL PROTECTED]
  w: www.eclimb.net
  _
  On Mar 29, 2004, at 10:29 AM, John W. Holmes wrote:
 
  From: Craig Hoffman [EMAIL PROTECTED]
  On Mar 29, 2004, at 10:06 AM, John W. Holmes wrote:
  From: Craig Hoffman [EMAIL PROTECTED]
 
  still no luck - any other suggestions?
 
  Please define no luck
 
  Yes of course.   Here is my new query.
 
SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'),
  WEEK(time_upload, '7') FROM TRAININGLOG WHERE DATE_SUB(
  NOW(),INTERVAL
  7 DAY ) = time_upload GROUP BY time_upload LIMIT 1
 
  So how does it not work? What are you expecting? What is returned? Is
  an
  error occuring or the wrong results or no results??
 
  ---John Holmes...
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] DATE_SUB Issues

2004-03-30 Thread Craig Hoffman
Thanks - I'll play with it today.
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
On Mar 30, 2004, at 3:32 AM, Ricardo Lopes wrote:
sorry, i press Control+Enter and i send the unfinished mail, here is 
the
continuation:

it worked because it was monday, probably today you arent happy.

try this sql, but i dont like the GROUP clause

SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'), 
WEEK(time_upload, 1)
FROM TRAININGLOG
WHERE (WEEK(NOW(), 1) = WEEK(time_upload, 1))
GROUP BY time_upload
LIMIT 1

- Original Message -
From: Craig Hoffman [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 29, 2004 9:48 PM
Subject: Re: [PHP-DB] DATE_SUB Issues

WooHoo!  I got it working!
Basically what I did is I changed this  DATE_SUB( NOW(),INTERVAL 7 DAY
)  to DATE_SUB( NOW(),INTERVAL 1 DAY ) and it worked.  I am not
entirely sure why.  Anyone know?
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
On Mar 29, 2004, at 10:56 AM, Craig Hoffman wrote:
What is should doing is grabbing all entries of this week and return 
a
total.  Its returning the wrong results.

SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'),
WEEK(time_upload, 1) FROM TRAININGLOG WHERE DATE_SUB( NOW(),INTERVAL 
7
DAY ) = time_upload GROUP BY time_upload LIMIT 1

= Results: (This is wrong)
= Weekly Miles: (Week starts on Monday)  5.34
Correct Results should be this:
Weekly Miles:   30.5
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
On Mar 29, 2004, at 10:29 AM, John W. Holmes wrote:
From: Craig Hoffman [EMAIL PROTECTED]
On Mar 29, 2004, at 10:06 AM, John W. Holmes wrote:
From: Craig Hoffman [EMAIL PROTECTED]

still no luck - any other suggestions?
Please define no luck
Yes of course.   Here is my new query.

  SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'),
WEEK(time_upload, '7') FROM TRAININGLOG WHERE DATE_SUB(
NOW(),INTERVAL
7 DAY ) = time_upload GROUP BY time_upload LIMIT 1
So how does it not work? What are you expecting? What is returned? 
Is
an
error occuring or the wrong results or no results??

---John Holmes...

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] DATE_SUB Issues

2004-03-30 Thread Craig Hoffman
sorry about the multiple reply's.  I tested the query with a few future 
dates and it seemed to be worked.  Thanks again for your help.

Thanks - Craig
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
On Mar 30, 2004, at 3:32 AM, Ricardo Lopes wrote:
sorry, i press Control+Enter and i send the unfinished mail, here is 
the
continuation:

it worked because it was monday, probably today you arent happy.

try this sql, but i dont like the GROUP clause

SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'), 
WEEK(time_upload, 1)
FROM TRAININGLOG
WHERE (WEEK(NOW(), 1) = WEEK(time_upload, 1))
GROUP BY time_upload
LIMIT 1

- Original Message -
From: Craig Hoffman [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 29, 2004 9:48 PM
Subject: Re: [PHP-DB] DATE_SUB Issues

WooHoo!  I got it working!
Basically what I did is I changed this  DATE_SUB( NOW(),INTERVAL 7 DAY
)  to DATE_SUB( NOW(),INTERVAL 1 DAY ) and it worked.  I am not
entirely sure why.  Anyone know?
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
On Mar 29, 2004, at 10:56 AM, Craig Hoffman wrote:
What is should doing is grabbing all entries of this week and return 
a
total.  Its returning the wrong results.

SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'),
WEEK(time_upload, 1) FROM TRAININGLOG WHERE DATE_SUB( NOW(),INTERVAL 
7
DAY ) = time_upload GROUP BY time_upload LIMIT 1

= Results: (This is wrong)
= Weekly Miles: (Week starts on Monday)  5.34
Correct Results should be this:
Weekly Miles:   30.5
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
On Mar 29, 2004, at 10:29 AM, John W. Holmes wrote:
From: Craig Hoffman [EMAIL PROTECTED]
On Mar 29, 2004, at 10:06 AM, John W. Holmes wrote:
From: Craig Hoffman [EMAIL PROTECTED]

still no luck - any other suggestions?
Please define no luck
Yes of course.   Here is my new query.

  SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'),
WEEK(time_upload, '7') FROM TRAININGLOG WHERE DATE_SUB(
NOW(),INTERVAL
7 DAY ) = time_upload GROUP BY time_upload LIMIT 1
So how does it not work? What are you expecting? What is returned? 
Is
an
error occuring or the wrong results or no results??

---John Holmes...

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] DATE_SUB Issues

2004-03-29 Thread Craig Hoffman
Hi There,
Perhaps someone could lend me a hand here on this query.  I have a 
query where I would like it to SUM up the last 7 days of records 
further, It needs  to start a new week on Monday. The 'time_upload' 
field is a  datetime field. What am I doing wrong or not doing here ?

SELECT SUM(distance), DATE_FORMAT('time_upload', '%u'), 
WEEK('time_upload', '7') FROM TRAININGLOG WHERE DATE_SUB(NOW(),INTERVAL 
7 DAY )
 =time_upload

Thanks,
Craig H.
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] DATE_SUB Issues

2004-03-29 Thread Craig Hoffman
still no luck - any other suggestions?
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
On Mar 29, 2004, at 8:18 AM, John W. Holmes wrote:
From: Craig Hoffman [EMAIL PROTECTED]

Perhaps someone could lend me a hand here on this query.  I have a
query where I would like it to SUM up the last 7 days of records
further, It needs  to start a new week on Monday. The 'time_upload'
field is a  datetime field. What am I doing wrong or not doing here ?
SELECT SUM(distance), DATE_FORMAT('time_upload', '%u'),
WEEK('time_upload', '7') FROM TRAININGLOG WHERE 
DATE_SUB(NOW(),INTERVAL
7 DAY )
 =time_upload
If time_upload is a column, it should not be between single quotes in 
the
WEEK() function.

---John Holmes...

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] DATE_SUB Issues

2004-03-29 Thread John W. Holmes
From: Craig Hoffman [EMAIL PROTECTED]

 still no luck - any other suggestions?

Please define no luck

---John Holmes...


 On Mar 29, 2004, at 8:18 AM, John W. Holmes wrote:
  From: Craig Hoffman [EMAIL PROTECTED]
 
  Perhaps someone could lend me a hand here on this query.  I have a
  query where I would like it to SUM up the last 7 days of records
  further, It needs  to start a new week on Monday. The 'time_upload'
  field is a  datetime field. What am I doing wrong or not doing here ?
 
  SELECT SUM(distance), DATE_FORMAT('time_upload', '%u'),
  WEEK('time_upload', '7') FROM TRAININGLOG WHERE 
  DATE_SUB(NOW(),INTERVAL
  7 DAY )
   =time_upload
 
  If time_upload is a column, it should not be between single quotes in 
  the
  WEEK() function.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] DATE_SUB Issues

2004-03-29 Thread Craig Hoffman
What is should doing is grabbing all entries of this week and return a 
total.  Its returning the wrong results.

SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'), WEEK(time_upload, 
1) FROM TRAININGLOG WHERE DATE_SUB( NOW(),INTERVAL 7 DAY ) = 
time_upload GROUP BY time_upload LIMIT 1

= Results: (This is wrong)
= Weekly Miles: (Week starts on Monday)  5.34
Correct Results should be this:
Weekly Miles:   30.5
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
On Mar 29, 2004, at 10:29 AM, John W. Holmes wrote:
From: Craig Hoffman [EMAIL PROTECTED]
On Mar 29, 2004, at 10:06 AM, John W. Holmes wrote:
From: Craig Hoffman [EMAIL PROTECTED]

still no luck - any other suggestions?
Please define no luck
Yes of course.   Here is my new query.

  SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'),
WEEK(time_upload, '7') FROM TRAININGLOG WHERE DATE_SUB( NOW(),INTERVAL
7 DAY ) = time_upload GROUP BY time_upload LIMIT 1
So how does it not work? What are you expecting? What is returned? Is 
an
error occuring or the wrong results or no results??

---John Holmes...

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] DATE_SUB Issues

2004-03-29 Thread Craig Hoffman
WooHoo!  I got it working!
Basically what I did is I changed this  DATE_SUB( NOW(),INTERVAL 7 DAY 
)  to DATE_SUB( NOW(),INTERVAL 1 DAY ) and it worked.  I am not 
entirely sure why.  Anyone know?
__
Craig Hoffman - eClimb Media

v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
On Mar 29, 2004, at 10:56 AM, Craig Hoffman wrote:
What is should doing is grabbing all entries of this week and return a 
total.  Its returning the wrong results.

SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'), 
WEEK(time_upload, 1) FROM TRAININGLOG WHERE DATE_SUB( NOW(),INTERVAL 7 
DAY ) = time_upload GROUP BY time_upload LIMIT 1

= Results: (This is wrong)
= Weekly Miles: (Week starts on Monday)  5.34
Correct Results should be this:
Weekly Miles:   30.5
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
On Mar 29, 2004, at 10:29 AM, John W. Holmes wrote:
From: Craig Hoffman [EMAIL PROTECTED]
On Mar 29, 2004, at 10:06 AM, John W. Holmes wrote:
From: Craig Hoffman [EMAIL PROTECTED]

still no luck - any other suggestions?
Please define no luck
Yes of course.   Here is my new query.

  SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'),
WEEK(time_upload, '7') FROM TRAININGLOG WHERE DATE_SUB( 
NOW(),INTERVAL
7 DAY ) = time_upload GROUP BY time_upload LIMIT 1
So how does it not work? What are you expecting? What is returned? Is 
an
error occuring or the wrong results or no results??

---John Holmes...

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php