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 SoftwareWebsite 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. 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 SoftwareWebsite 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:
OT: Textarea (2003)
Document Contains No Data! (1997)
RE: [WebDNA] Tables... (2008)
OT: Backup Strategies (2007)
[group] ? (1997)
[WebDNA] test (2010)
Payment Calculator? (2000)
RE: File Uploads (1998)
unique ascending numbers (2003)
Webstar SSL and Non-SSL question (1998)
security (1997)
WCf2 and nested tags (1997)
Return records from another (1997)
Separate SSL Server (1997)
Database Helper Update (1998)
Help with [LineItems] in [OrderFile] on ShoppingCart.tpl (2003)
WebCat2b14MacPlugIn - [include] doesn't hide the search string (1997)
Limit on nested [ShowIf]'s? (1997)
emailer on Windows Beta 18 (1997)
NewCart+Search with one click ? (1997)