Re: separate by mont (search)

This WebDNA talk-list message is from

2002


It keeps the original formatting.
numero = 46454
interpreted = N
texte = >>1. In a database I have one of the entries as a date in this format >>mm/dd/yyyy. > >No matter what other methods you use to store dates in a db, it is always a good idea to store the month, day and year in three separate fields in your db's ... for the exact reason that you've described here:There can be some advantages, but it's certainly not necessary. If it's not being done that way now I wouldn't change it.> >>3. The customer wants to be able to display information by month >>4. A search should display the months ie: Jan, Feb, Mar, Apr, etc.. > >There is a way -- but it is convoluted and unintuitive at best, and I disposed of it as a standard coding technique years ago -- in favor of storing my dates in three separate fields.How is this convoluted: [loop start=1&end=12][lookup db=int2month.db&lookinfield=int&value=[index]&returnfield=month][/loop]?> >It is far simpler to store the three components of a date in three separate fields. Not only does this make all kinds of date searches extremely easy to code (and easy to modify or debug), it also means you can use three popup fields for dates in all your forms, with each form field corresponding directly to one of your three date component fields. > >By the way, if you happened to store your dates as the number of days since 0000 via the [math]{[date]}[/math] technique, there's no reasonable way to extract the values in a particular month -- so this technique is not good at all for searching by a particular month or year ...Actually, if you did do this it is extremely easy to find all the january records. Just do an integer search greater than or equal to [math]{[month]/1/[year]}[/math] and less than [math]{[month]/1/[year(maybe +1)]}[/math] - This is extremely fast and simple. -- --------------------------------- John A. Hill Oak Hill Software Website Development/Consulting john@oakhillsoftware.com------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: separate by mont (search) (John Hill 2002)
  2. Re: separate by mont (search) (Sam Lewis 2002)
  3. Re: separate by mont (search) (Kenneth Grome 2002)
  4. Re: separate by mont (search) (John Hill 2002)
  5. separate by mont (search) (Arturo Vargas 2002)
>>1. In a database I have one of the entries as a date in this format >>mm/dd/yyyy. > >No matter what other methods you use to store dates in a db, it is always a good idea to store the month, day and year in three separate fields in your db's ... for the exact reason that you've described here:There can be some advantages, but it's certainly not necessary. If it's not being done that way now I wouldn't change it.> >>3. The customer wants to be able to display information by month >>4. A search should display the months ie: Jan, Feb, Mar, Apr, etc.. > >There is a way -- but it is convoluted and unintuitive at best, and I disposed of it as a standard coding technique years ago -- in favor of storing my dates in three separate fields.How is this convoluted: [loop start=1&end=12][lookup db=int2month.db&lookinfield=int&value=[index]&returnfield=month][/loop]?> >It is far simpler to store the three components of a date in three separate fields. Not only does this make all kinds of date searches extremely easy to code (and easy to modify or debug), it also means you can use three popup fields for dates in all your forms, with each form field corresponding directly to one of your three date component fields. > >By the way, if you happened to store your dates as the number of days since 0000 via the [math]{[date]}[/math] technique, there's no reasonable way to extract the values in a particular month -- so this technique is not good at all for searching by a particular month or year ...Actually, if you did do this it is extremely easy to find all the january records. Just do an integer search greater than or equal to [math]{[month]/1/[year]}[/math] and less than [math]{[month]/1/[year(maybe +1)]}[/math] - This is extremely fast and simple. -- --------------------------------- John A. Hill Oak Hill Software Website Development/Consulting john@oakhillsoftware.com------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ John Hill

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:

Problems passing [SKU] with $Replace in 2.0 (1997) WebCatb15 Mac CGI -- [purchase] (1997) Re:2nd WebCatalog2 Feature Request (1996) WebCatalog and WebMerchant reviewed by InfoWorld (1997) What folder??? (1999) slowness (1998) More on [purchase] (1998) 5.1: Can't enter serial number (2004) remotely add + sign (1997) [OT] - Block Traffic to DevBox (2003) customer info (2001) Searching using numbers (1998) Running 2 two WebCatalog.acgi's (1996) [shownext max=?] armed (1997) Expiration of Carts (1997) Sku numbers (1997) Permissions (2002) WebCat2b13 Command Reference Doc error (1997) Notepad problems (1998) Upgrading old WebCat Database Files (1997)