Group by defined period

latex88

Registered User.
Local time
Yesterday, 18:42
Joined
Jul 10, 2003
Messages
198
Hi,

How would I go about grouping a set of data by a defined period? Let's say I have data from year 2010 - 2012, and I want to pull data that is grouped by every 15 days, 5 weeks, 6 months, whatever time period?
 
Hi,

This should achieve what you want, just change the number 60 to the number of days you want to group by, and change the field and table names to match your data.

Code:
SELECT Int(([[COLOR=red]DateFieldName[/COLOR]]-DMin("[COLOR=red]DateFieldName[/COLOR]","[COLOR=red]TableName[/COLOR]"))/60) AS DateGroup
FROM [COLOR=red]TableName
[/COLOR]GROUP BY Int(([[COLOR=#ff0000]DateFieldName[/COLOR]]-DMin("[COLOR=#ff0000]DateFieldName[/COLOR]","[COLOR=#ff0000]TableName[/COLOR]"))/60);
 

Users who are viewing this thread

Back
Top Bottom