ruby on rails - Grouping records more than 30 minutes apart -


let's have 2 models, visitor , visits. possible group visits particular visitor no more 30 minutes apart (or time interval really). split visits there gap of more 30 minutes. e.g. if visits created @ 10:00, 10:05, 10:14, 11:20, 11:30 2 groups: 10:00, 10:05, 10:14 , 11:20, 11:30. thanks!

select to_timestamp(floor((extract('epoch' your_timestamp_column) / 1800 )) * 1800) table group to_timestamp(floor((extract('epoch' your_timestamp_column) / 1800 )) * 1800) 

will give times @ 30 minute intervals.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -