dbTalk Databases Forums  

Group timestamp by hour?

comp.databases.paradox comp.databases.paradox


Discuss Group timestamp by hour? in the comp.databases.paradox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jan
 
Posts: n/a

Default Group timestamp by hour? - 05-20-2006 , 11:57 AM






Is it easy to create a query that counts the number of timestamps in a
table grouped by hour? Or group people's ages based on their based on
today - DOB?


Reply With Quote
  #2  
Old   
Ed Covney
 
Posts: n/a

Default Re: Group timestamp by hour? - 05-20-2006 , 02:41 PM






Quote:
Is it easy to create a query that counts the number of timestamps in a
table grouped by hour? Or group people's ages based on their based on
today - DOB?


Yes & yes.

Whether it can be done directly is another matter.

What I'd do is create computed fields for ages and
hours and group on those fields (they can be hidden).

For example, to calculate your "new" age in years
field (Dobfld = your current date of birth field) :

iif (doy(Today() < doy(Dobfld),
year(Today())-year(Dobfld)-1,
year(Today())-year(Dobfld) )


Ed




Reply With Quote
  #3  
Old   
Larry DiGiovanni
 
Posts: n/a

Default Re: Group timestamp by hour? - 05-20-2006 , 11:09 PM



Jan wrote:

Quote:
Is it easy to create a query that counts the number of timestamps in a
table grouped by hour?
Create two SQL queries:

SELECT EXTRACT(hour FROM yourtimestampfield) as tsHour FROM yourtable

save that query and call it q1.sql

Now in a second query:

SELECT tsHour, COUNT(*)
FROM q1.sql
GROUP BY tsHour

You can't do it in one step because Local SQL won't group by an extract.
Most other dialects will.

You can avoid querying a query by creating an Hours table with a single
field theHour and populate it from 1 to 12, then join to it in a single
query:

SELECT h.theHour, COUNT(*)
FROM yourtable, hours
WHERE EXTRACT(hour FROM yourtimefield) = theHour
GROUP BY theHour

Quote:
Or group people's ages based on their based on
today - DOB?
In a QBE query:

table | DOB |
Quote:
_dob, CALC TODAY - dob |
Then query the result with groupings. The ages given will be in days.

--
Larry DiGiovanni
Digico, Inc.
IT Consulting and Staffing Solutions
www.digicoinc.com
Check out www.thedbcommunity.com for Paradox resources.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.