Jump to content

Recommended Posts

Hi,

 

select * from `tablename` where 'fieldname` < now() and fieldname` > (now()-interval 1 day);

 

This gives the result of all the records for 24 hours.

 

 

The timestamp stored in database is like this:

2007-09-16 19:30:02 |

| 2007-09-16 19:40:02 |

| 2007-09-16 19:50:02 |

| 2007-09-16 20:00:02 |

| 2007-09-16 20:10:02 |

| 2007-09-16 20:20:02 |

| 2007-09-16 20:30:02 |

| 2007-09-16 20:40:02 |

| 2007-09-16 20:50:02 |

| 2007-09-16 21:00:01 |

| 2007-09-16 21:10:02 |

| 2007-09-16 21:30:02 |

| 2007-09-16 21:30:02 |

| 2007-09-16 21:40:02

 

 

 

How to write a query to fetch data between these two 2007-09-16 21:40:02 and 2007-09-16 21:30:02 and

2007-09-16 21:30:02 and 2007-09-16 21:30:02 and so on........

 

Between these timestamps there is a records.

I should find the average between each timestamps

 

 

Please help me in writing a query to find the average of each ten minutes records in database from current timestamp to previous day

Link to comment
https://forums.phpfreaks.com/topic/69861-query/
Share on other sites

Finding the records between each 10 mints interval is not a problem , but grouping them to find avg of timestamps with a groupcolumn which has a unique value for each interval is the problem.

 

As we can't loop it for each interval using MySQL better try with PHP.

 

 

Link to comment
https://forums.phpfreaks.com/topic/69861-query/#findComment-351254
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.