Group by defined period (1 Viewer)

latex88

Registered User.
Local time
Today, 06:08
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?
 

sparks80

Physicist
Local time
Today, 12:08
Joined
Mar 31, 2012
Messages
223
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

Top Bottom