Re: Date or time comparisons have bugs ...
This WebDNA talk-list message is from 1998
It keeps the original formatting.
numero = 16983
interpreted = N
texte = Ken-The problem is not in your [Search] parameters, but in the fact that youare doing a [Delete] within a [FoundItems] loop.I'm sure that Grant can explain this better than I can, but when you do asearch, WebCat creates its own internal list of matching items andremembers them by their positions in the database. [FoundItems] then loopsthrough each of those records, first performing the desired operations onthe first found record in the db, then on the second, etc. Having a[Delete] inside [FoundItems] messes this up, because it changes theposition of records in your database.For example, say the [Search] finds records 1,2,and 6. On the first[FoundItems] loop, record 1 is deleted. With record 1 gone, the originalrecord 2 becomes record 1, and every other record moves up a position(2->1, 3->2, 4->3, etc.). So when [FoundItems] comes through looking forrecord 2, it is really finding the original record 3, which may or may nothave met the search criteria. The original record 2 gets skipped altogether.Of course, you can avoid all of this by building the search criteria intoyour [Delete]:[Deletedb=this.db&ledeleteDatedatarq=[date]&ledeleteTimedatarq=[time]&deleteDatetype=date]-Dave>Date: 9 Apr 1998 08:26:04>From: Kenneth Grome
>Subject: Date or time comparisons have bugs ...>>I have three fields in this.db: cartID, deleteDate and deleteTime,>corresponding to the following data:>>296987757 02/10/1998 13:59:35>296987758 02/10/1998 13:59:49>296987760 02/10/1998 14:00:00>297229722 03/10/1998 14:07:10>297422049 04/01/1998 20:21:39>297489625 04/09/1998 16:04:12>297489636 04/09/1998 16:06:08>>>My code, which is designed to delete records, looks like this:>>[search>db=this.db&ledeleteDatedatarq=[date]&ledeleteTimedatarq=[time]&deleteDatetype=d>ate]>[founditems]>[delete db=this.db&eqcartIDdatarq=[cartID]]>[/founditems]>[/search]>>So why doesn't it delete all but the last three records?>>Clearly it *should* delete the first 4 records because both the dates AND the>times are *less than* the current date and time, which is 04/08/1998 and>16:12:00 ... so, is there a bug in WebCatalog's code that's causing this>problem?>>Or is there a better way of coding this stuff so that it actually works?>>Sincerely,>Ken Grome>808-737-6499>WebDNA Solutions>mailto:ken@webdna.net>http://www.webdna.net>o--------------- Dave MacLeay --+o----------- Digital Frontier --+o--- dave@digitalfrontier.com --+
Associated Messages, from the most recent to the oldest:
Ken-The problem is not in your [search] parameters, but in the fact that youare doing a [delete] within a [founditems] loop.I'm sure that Grant can explain this better than I can, but when you do asearch, WebCat creates its own internal list of matching items andremembers them by their positions in the database. [founditems] then loopsthrough each of those records, first performing the desired operations onthe first found record in the db, then on the second, etc. Having a[delete] inside [founditems] messes this up, because it changes theposition of records in your database.For example, say the [search] finds records 1,2,and 6. On the first[founditems] loop, record 1 is deleted. With record 1 gone, the originalrecord 2 becomes record 1, and every other record moves up a position(2->1, 3->2, 4->3, etc.). So when [founditems] comes through looking forrecord 2, it is really finding the original record 3, which may or may nothave met the search criteria. The original record 2 gets skipped altogether.Of course, you can avoid all of this by building the search criteria intoyour [delete]:[Deletedb=this.db&ledeleteDatedatarq=[date]&ledeleteTimedatarq=[time]&deleteDatetype=date]-Dave>Date: 9 Apr 1998 08:26:04>From: Kenneth Grome >Subject: Date or time comparisons have bugs ...>>I have three fields in this.db: cartID, deleteDate and deleteTime,>corresponding to the following data:>>296987757 02/10/1998 13:59:35>296987758 02/10/1998 13:59:49>296987760 02/10/1998 14:00:00>297229722 03/10/1998 14:07:10>297422049 04/01/1998 20:21:39>297489625 04/09/1998 16:04:12>297489636 04/09/1998 16:06:08>>>My code, which is designed to delete records, looks like this:>>[search>db=this.db&ledeleteDatedatarq=[date]&ledeleteTimedatarq=[time]&deleteDatetype=d>ate]>[founditems]>[delete db=this.db&eqcartIDdatarq=[cartID]]>[/founditems]>[/search]>>So why doesn't it delete all but the last three records?>>Clearly it *should* delete the first 4 records because both the dates AND the>times are *less than* the current date and time, which is 04/08/1998 and>16:12:00 ... so, is there a bug in WebCatalog's code that's causing this>problem?>>Or is there a better way of coding this stuff so that it actually works?>>Sincerely,>Ken Grome>808-737-6499>WebDNA Solutions>mailto:ken@webdna.net>http://www.webdna.net>o--------------- Dave MacLeay --+o----------- Digital Frontier --+o--- dave@digitalfrontier.com --+
Dave MacLeay
DOWNLOAD WEBDNA NOW!
Top Articles:
Talk List
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...
Related Readings:
Setting Cart value (2000)
difference between v.6 and v.7, WAS: [WebDNA] v7 thisurl has different behavour (2012)
Final Receipt (1999)
3 card formulas! (1999)
automatic reload of frameset (1997)
Upgrade to 3.07 problems (2000)
Emailer (WebCat2) (1997)
Tab Charactor (1997)
image attachment (2002)
[isfolder] and [filename] (1997)
OT: Sendmail (2005)
Calculating multiple shipping... (1997)
oddball sorting problem (2003)
OFF-TOPIC: Lending investors ... (2002)
Fun with Dates - any progress? (1997)
HELLO (2000)
WC2b15 File Corruption (1997)
test (2000)
OT: Too many lines too add in one go (2003)
Cannot calculate prices (1997)