|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
date_sub function issues
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 (one week), it needs to start a new week on Monday. The 'time_upload' field is a datetime field. Currently the results I am getting at all the rows being added. What am I doing wrong or not doing here ? $query = "SELECT SUM(distance) FROM TRAININGLOG WHERE DATE_SUB( NOW(),INTERVAL 7 DAY ) <= time_upload "; Thanks, Craig H. |
|
#2
|
|||
|
|||
|
$query = "SELECT SUM(distance) FROM TRAININGLOG WHERE time_upload >= DATE_SUB( NOW(),INTERVAL 7 DAY ) ";
your field in the table is 'time_upload'. probably you would need this field to be the reference in the condition, not date_sub(...). i hope this works. worth a try ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > date_sub function issues |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|