Re: [sqlite] tricky date time problem

2005-02-24 Thread Lloyd Thomas
Dennis Might be someting to do with version 2.8.15. I have tried as is and I get an error "sql error near 'Select': syntax error" Lloyd - Original Message - From: "Dennis Cote" <[EMAIL PROTECTED]> To: Sent: Thursday, February 24, 2005 1:31 AM Su

Re: [sqlite] tricky date time problem

2005-02-24 Thread Lloyd Thomas
Dennis, syntax error somewhere. 'group by minute union select 0, 0 where not exists (select * from event_data)' Lloyd - Original Message - From: "Dennis Cote" <[EMAIL PROTECTED]> To: Sent: Thursday, February 24, 2005 1:31 AM Subject: Re: [sqlite] tricky date

Re: [sqlite] tricky date time problem

2005-02-23 Thread Dennis Cote
On Wed, 23 Feb 2005 23:12:41 -, Lloyd Thomas <[EMAIL PROTECTED]> wrote: > Dennis, > Thanks for you help so far. I think it is easier for PHP to select > the MAX event. The problem I now have is if there is no records for an hour, > PHP will through up an error because MAX must have at l

Re: [sqlite] tricky date time problem

2005-02-23 Thread Dennis Cote
Lloyd, A small improvement is to limit the number of rows used to test for event existence. This avoid scanning the whole event_data table if there are many events. select minutes.i as minute, count(*) as events from (select (event_time / 60) % 60 as begin_minute, ((event_time + durati

Re: [sqlite] tricky date time problem

2005-02-23 Thread Lloyd Thomas
- From: "Dennis Cote" <[EMAIL PROTECTED]> To: "sqlite-users" Sent: Wednesday, February 23, 2005 8:51 PM Subject: Re: [sqlite] tricky date time problem Dennis Cote wrote: I though you wanted the minute with the most events. I added the outer select to show that th

Re: [sqlite] tricky date time problem

2005-02-23 Thread Dennis Cote
Dennis Cote wrote: I though you wanted the minute with the most events. I added the outer select to show that that step can be done easily in the same query, rather than relying on PHP to extract this info from the full results for the hour. But of course that portion of the query doesn't work t

Re: [sqlite] tricky date time problem

2005-02-23 Thread Dennis Cote
Lloyd Thomas wrote: Revisted your query. I was being a bit lazy. changed 'select minute, max(events)' to 'select minute, events' and added 'order by minute' to give me what I needed. Thanks Lloyd, If you want the whole table simply remove the outer select and add the order by clause as below.

Re: [sqlite] tricky date time problem

2005-02-23 Thread Lloyd Thomas
ECTED]> To: "sqlite-users" Sent: Wednesday, February 23, 2005 5:41 PM Subject: Re: [sqlite] tricky date time problem Lloyd, I messed up the math for the end minute calculation. :-[ The correct query is given below. Adding 59 was intended to round the result of an integer division (w

Re: [sqlite] tricky date time problem

2005-02-23 Thread Lloyd Thomas
indicate where I am going wrong. Lloud - Original Message - From: "Jay" <[EMAIL PROTECTED]> To: ; <[EMAIL PROTECTED]> Sent: Wednesday, February 23, 2005 5:39 PM Subject: Re: [sqlite] tricky date time problem --- Lloyd Thomas <[EMAIL PROTECTE

Re: [sqlite] tricky date time problem

2005-02-23 Thread Dennis Cote
Lloyd, I messed up the math for the end minute calculation. :-[ The correct query is given below. Adding 59 was intended to round the result of an integer division (which drops the remainder), but I'm actually keeping the reminader and throwing away the quotient so it was simply wrong. selec

Re: [sqlite] tricky date time problem

2005-02-23 Thread Jay
--- Lloyd Thomas <[EMAIL PROTECTED]> wrote: > Thanks Jay/DRH, > this looks more promising (The "%" > operator > gives you remainder after division). Still not sure how I could apply > it to > start and end unix times. > The columns I have are :- > hour start = start

Re: [sqlite] tricky date time problem

2005-02-23 Thread Dennis Cote
Lloyd Thomas wrote: I have two tables the event table which holds the data and a table which has an entry for each minute CREATE TABLE event_data ( call_id INTEGER PRIMARY KEY, desc varchar(32) NOT NULL default '', event_time datetime default NULL, stamptime integer default NULL, duration in

Re: [sqlite] tricky date time problem

2005-02-23 Thread Uriel_Carrasquilla
n.plus.com> cc: Subject: Re: [sqlite] tricky date time problem 02/22/2005 06:41 PM

Re: [sqlite] tricky date time problem

2005-02-23 Thread Lloyd Thomas
sults 'i' as a datatime modifier in the event_data table. Not much luck though. - Original Message - From: "D. Richard Hipp" <[EMAIL PROTECTED]> To: Sent: Wednesday, February 23, 2005 12:26 PM Subject: Re: [sqlite] tricky date time problem On Mon, 2005-02-21 at 21

Re: [sqlite] tricky date time problem

2005-02-23 Thread D. Richard Hipp
On Mon, 2005-02-21 at 21:49 +, Lloyd Thomas wrote: > I have a query which calculates the number of events during an hour by the > minute. It needs to work out which minute has the most events and the > average events during that hour. So it should return an array of 60 results > for an hou

Re: [sqlite] tricky date time problem

2005-02-23 Thread Lloyd Thomas
ion <= 1081335540 The result I get is 0|15 I was expecting 60 result rows any Ideas? Is this a version 3 operator only? - Original Message - From: "Lloyd Thomas" <[EMAIL PROTECTED]> To: Sent: Tuesday, February 22, 2005 11:41 PM Subject: Re: [sqlite] tricky date time pr

Re: [sqlite] tricky date time problem

2005-02-22 Thread Lloyd Thomas
quot; <[EMAIL PROTECTED]> To: Sent: Tuesday, February 22, 2005 2:47 PM Subject: Re: [sqlite] tricky date time problem --- "D. Richard Hipp" <[EMAIL PROTECTED]> wrote: > It's too bad Sqlite doesn't have the modulo operator, The "%" operator gives you r

Re: [sqlite] tricky date time problem

2005-02-22 Thread Jay
--- "D. Richard Hipp" <[EMAIL PROTECTED]> wrote: > > It's too bad Sqlite doesn't have the modulo operator, > > The "%" operator gives you remainder after division, > which is very close to being a modulo operator. Thanks! I went looking for the page in the documentation about expressions to

Re: [sqlite] tricky date time problem

2005-02-22 Thread Jan Ekström
Is there a best way to administrate SQLite? Do I use PHP, TCL C or .? Sincerely Jan Ekström - Original Message - From: "D. Richard Hipp" <[EMAIL PROTECTED]> To: Sent: Tuesday, February 22, 2005 2:18 PM Subject: Re: [sqlite] tricky date time problem On Mon, 200

Re: [sqlite] tricky date time problem

2005-02-22 Thread D. Richard Hipp
On Mon, 2005-02-21 at 18:00 -0800, Jay wrote: > It's too bad Sqlite doesn't have the modulo operator, The "%" operator gives you remainder after division, which is very close to being a modulo operator. -- D. Richard Hipp <[EMAIL PROTECTED]>

Re: [sqlite] tricky date time problem

2005-02-22 Thread Jay
upings very simply. If you can write a > | > |user defined function in whatever language you're using >| > |you might try that. > | > --- > How would you do that in C? > > - Original Message - > From: "Jay" <[EMAIL PROTECTED]> >

Re: [sqlite] tricky date time problem

2005-02-22 Thread Lloyd Thomas
might try that. | --- How would you do that in C? - Original Message - From: "Jay" <[EMAIL PROTECTED]> To: ; <[EMAIL PROTECTED]> Sent: Tuesday, February 22, 2005 2:00 AM Subject: Re: [sqlite] tricky da

Re: [sqlite] tricky date time problem

2005-02-21 Thread Jay
--- Lloyd Thomas <[EMAIL PROTECTED]> wrote: > I have a query which calculates the number of events during an hour > by the > minute. It needs to work out which minute has the most events and > the > average events during that hour. So it should return an array of 60 > results > for an hour w

Re: [sqlite] tricky date time problem

2005-02-21 Thread Lloyd Thomas
4-07 10:00','+i+1 minutes') ORDER BY i , call_time; May it be something to do with the 'i' not being seen as an integer for the datetime modifier? - Original Message - From: "Roger Binns" <[EMAIL PROTECTED]> To: Sent: Tuesday, February 22, 2005 12:02

Re: [sqlite] tricky date time problem

2005-02-21 Thread Roger Binns
I have a query which calculates the number of events during an hour by the minute. It needs to work out which minute has the most events and the average events during that hour. So it should return an array of 60 results for an hour where I can use the MAX() feature in php to find the peak mi

Re: [sqlite] tricky date time problem

2005-02-21 Thread Lloyd Thomas
me between datetime('2004-04-07 10:00:00','+1 minutes') and datetime ('2004-04-07 10:59:59','+1 minutes'); returns nothing. Am I using the right datetime modifiers? - Original Message - From: "Lloyd Thomas" <[EMAIL PROTECTED]> To:

[sqlite] tricky date time problem

2005-02-21 Thread Lloyd Thomas
I have a query which calculates the number of events during an hour by the minute. It needs to work out which minute has the most events and the average events during that hour. So it should return an array of 60 results for an hour where I can use the MAX() feature in php to find the peak mi