Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calculating date values

Status
Not open for further replies.

dude333

Programmer
Feb 5, 2004
11
GB
Hi,

I want to add all the time values from one column in a table for the last 7 days of entries.

Can anyone tell me the most effective way of doing this, is there a quick an easy wy to do this with mysql or is it better to write a php function.

Thanks.
 
SELECT sec_to_time(sum(time_to_sec(yourfield)))
FROM yourtable
WHERE yourdatefield >= DATE_SUB(CURDATE(), INTERVAL 7 DAY));
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top