WebDNA Solutions --> Date format suggestions

This WebDNA talk-list message is from

1998


It keeps the original formatting.
numero = 17638
interpreted = N
texte = >>>The following search in one of my templates works fine, but >>>this one causes WebSTAR to pause for a moment, and usually crash:>> [snip]>>I would suggest changing all the dates in your db from formatted dates (such as 05/12/1998) to the number of days since 00/00/0000. That's what I did in order to get WebCat to repond relatively quickly to date searches ...>Thanks for the tips, Ken. Any hints on how in the worId I would >write the date to a database as the number of days since >00/00/0000? Here's a WebDNA template page with everything you need. Since I cannot attach the following web page as a separate file, you will need to copy and paste the following code into a brand new text file, then name the file with a WebDNA suffix (such as dates.tpl), put it on your web site, and call the page via http from your web browser.If you follow the guidelines in this file, your date searches will be performed as quickly as possible with either WebCatalog or Typhoon.Please note, there are *SOME* situations where my guidelines will need to be modified -- such as dates outside a particular date range. But if all your dates are between 274 AD and 2738 AD, these suggestions and the enclosed examples will work just fine ... :)----- start webdna template -----
WebDNA Date Formatting Guidelines
Courtesy of WebDNA Solutions



This page has copy-and-paste examples of the proper WebDNA tags to use when your default DateFormat (in the WebCatalog Prefs or Typhoon Prefs file) is set to %m/%d/%Y and when all the dates in your database files are stored as the number of days since 00/00/0000. This page shows you how to store dates in this format, and how to search for and display those dates, too.

By following these guidelines and using the tags and parameters below, your code will be easier to write and your databases will store the smallest possible dates, thus conserving both RAM and disk space. In addition, your searches will run faster because they will not rely on interpretation of formatted date values in the database.

Please note, there are some situations where these examples might need to be modified -- such as when your dates fall outside the recommended date range. But if all your d! ates are between 274 AD and 2738 AD, these examples will work just fine simply by changing the specific numeric values to match your needs.

The best way to use this page is to place it on your web server, then request it whenever you need a quick reference to dealing with dates in your WebDNA templates ... :)

 

 
Storing dates in database fields:       (dates are always stored as the number of days since January 1, 0000)
 
Today's date:   [raw][math]{[date]}[/math][/raw]   [math]{[date]}[/math]
 
One week ago:   [raw][math]{[date]}-{00/07/0000}[/math][/raw]   [math]{[date]}-{00/07/0000}[/math]
One week ago (short cut code):   [raw][math]{[date]}-7[/math][/raw]   [math]{[date]}-7[/math]
 
Two months ago:   [raw][math]{[date]}-{02/00/0000}[/math][/raw]   [math]{[date]}-{02/00/0000}[/math]
Three years ago:   [raw][math]{[date]}-{00/00/0003}[/math][/raw]   [math]{[date]}-{00/00/0003}[/math]
 
One week in the future:   [raw][math]{[date]}+{00/07/0000}[/math][/raw]   [math]{[date]}+{00/07/0000}[/math]
20 months in the future:   [raw][math]{[date]}+{20/00/0000}[/math][/raw]   [math]{[date]}+{20/00/0000}[/math]
500 days in the future:   [raw][math]{[date]}+{00/500/0000}[/math][/raw]   [math]{[date]}+{00/500/0000}[/math]
 

 
Search parameters using dates:       (when using rn, make sure the smallest range value always appears first)
 
FInd any date in the future:   [raw]&grFieldNamedatarq=[math]{[date]}[/math][/raw]
FInd today's date:   [raw]&eqFieldNamedatarq=[math]{[date]}[/math][/raw]
Find any previous date:   [raw]&lsFieldNamedatarq=[math]{[date]}[/math][/raw]
 
Dates ranging from 0-1 week ago:   [raw]&rnFieldNamedatarq=[math]{[date]}-7[/math],[math]{[date]}[/math][/raw]
Dates ranging from 1-2 weeks ago:   [raw]&rnFieldNamedatarq=[math]{[date]}-14[/math],[math]{[date]}-7[/math][/raw]
Dates from 0-1 week in the future:   [raw]&rnFieldNamedatarq=[math]{[date]}[/math],[math]{[date]}+7[/math][/raw]
Dates from 1-2 weeks in the future:   [raw]&rnFieldNamedatarq=[math]{[date]}+7[/math],[math]{[date]}+14[/math][/raw]
4 months ago thru 35 days in the future:   [raw]&rnFieldNamedatarq=[math]{[date]}-{04/00/0000}[/math],[math]{[date]}+{00/35/0000}[/math][/raw]
16 years 7 months ago thru today:   [raw]&rnFieldNamedatarq=[math]{[date]}-{07/00/0016}[/math],[math]{[date]}[/math][/raw]
 

 
Displaying dates in web pages:
 
A database field date (default format):   [raw][format days_to_date][FieldName][/format][/raw]   [format days_to_date][math]729855[/math][/format]
A db field date with a different format:   [raw][format days_to_date %d.%m.%Y][FieldName][/format][/raw]   [format days_to_date %d.%m.%Y][math]{[date]}[/math][/format]
 
One week earlier than a db field date:   [raw][format days_to_date][math][FieldName]-7[/math][/format][/raw]   [format days_to_date][math]729855-7[/math][/format]
One week later than a db field date:   [raw][format days_to_date][math][FieldName]+7[/math][/format][/raw]   [format days_to_date][math]729855+7[/math][/format]
 
Today's date (default format):   [raw][date][/raw]   [date]
Today's date in a different format:   [raw][date %d.%m.%Y][/raw]   [date %d.%m.%Y]
 
One week ago today:   [raw][math date]{[date]}-{00/07/0000}[/math][/raw]   [math date]{[date]}-{00/07/0000}[/math]
One month ago today:   [raw][math date]{[date]}-{01/00/0000}[/math][/raw]   [math date]{[date]}-{01/00/0000}[/math]
One year ago today:   [raw][math date]{[date]}-{00/00/0001}[/math][/raw]   [math date]{[date]}-{00/00/0001}[/math]
 
One week in the future:   [raw][math date]{[date]}+{00/07/0000}[/math][/raw]   [math date]{[date]}+{00/07/0000}[/math]
One month in the future:   [raw][math date]{[date]}+{01/00/0000}[/math][/raw]   [math date]{[date]}+{01/00/0000}[/math]
One year in the future:   [raw][math date]{[date]}+{00/00/0001}[/math][/raw]   [math date]{[date]}+{00/00/0001}[/math]
 


These guidelines are provided free of charge courtesy of WebDNA Solutions.


Associated Messages, from the most recent to the oldest:

    
  1. Re: WebDNA Solutions --> Date format suggestions (mgcamp@gulftel.com (Morris Camp) 1998)
  2. Re: WebDNA Solutions --> Date format suggestions (Gil Poulsen 1998)
  3. Re: WebDNA Solutions --> Date format suggestions (Kenneth Grome 1998)
  4. WebDNA Solutions --> Date format suggestions (Kenneth Grome 1998)
>>>The following search in one of my templates works fine, but >>>this one causes WebSTAR to pause for a moment, and usually crash:>> [snip]>>I would suggest changing all the dates in your db from formatted dates (such as 05/12/1998) to the number of days since 00/00/0000. That's what I did in order to get WebCat to repond relatively quickly to date searches ...>Thanks for the tips, Ken. Any hints on how in the worId I would >write the date to a database as the number of days since >00/00/0000? Here's a WebDNA template page with everything you need. Since I cannot attach the following web page as a separate file, you will need to copy and paste the following code into a brand new text file, then name the file with a WebDNA suffix (such as dates.tpl), put it on your web site, and call the page via http from your web browser.If you follow the guidelines in this file, your date searches will be performed as quickly as possible with either WebCatalog or Typhoon.Please note, there are *SOME* situations where my guidelines will need to be modified -- such as dates outside a particular date range. But if all your dates are between 274 AD and 2738 AD, these suggestions and the enclosed examples will work just fine ... :)----- start webdna template -----
WebDNA Date Formatting Guidelines
Courtesy of WebDNA Solutions



This page has copy-and-paste examples of the proper WebDNA tags to use when your default DateFormat (in the WebCatalog Prefs or Typhoon Prefs file) is set to %m/%d/%Y and when all the dates in your database files are stored as the number of days since 00/00/0000. This page shows you how to store dates in this format, and how to search for and display those dates, too.

By following these guidelines and using the tags and parameters below, your code will be easier to write and your databases will store the smallest possible dates, thus conserving both RAM and disk space. In addition, your searches will run faster because they will not rely on interpretation of formatted date values in the database.

Please note, there are some situations where these examples might need to be modified -- such as when your dates fall outside the recommended date range. But if all your d! ates are between 274 AD and 2738 AD, these examples will work just fine simply by changing the specific numeric values to match your needs.

The best way to use this page is to place it on your web server, then request it whenever you need a quick reference to dealing with dates in your WebDNA templates ... :)

 

 
Storing dates in database fields:       (dates are always stored as the number of days since January 1, 0000)
 
Today's date:   [raw][math]{[date]}[/math][/raw]   [math]{[date]}[/math]
 
One week ago:   [raw][math]{[date]}-{00/07/0000}[/math][/raw]   [math]{[date]}-{00/07/0000}[/math]
One week ago (short cut code):   [raw][math]{[date]}-7[/math][/raw]   [math]{[date]}-7[/math]
 
Two months ago:   [raw][math]{[date]}-{02/00/0000}[/math][/raw]   [math]{[date]}-{02/00/0000}[/math]
Three years ago:   [raw][math]{[date]}-{00/00/0003}[/math][/raw]   [math]{[date]}-{00/00/0003}[/math]
 
One week in the future:   [raw][math]{[date]}+{00/07/0000}[/math][/raw]   [math]{[date]}+{00/07/0000}[/math]
20 months in the future:   [raw][math]{[date]}+{20/00/0000}[/math][/raw]   [math]{[date]}+{20/00/0000}[/math]
500 days in the future:   [raw][math]{[date]}+{00/500/0000}[/math][/raw]   [math]{[date]}+{00/500/0000}[/math]
 

 
Search parameters using dates:       (when using rn, make sure the smallest range value always appears first)
 
FInd any date in the future:   [raw]&grFieldNamedatarq=[math]{[date]}[/math][/raw]
FInd today's date:   [raw]&eqFieldNamedatarq=[math]{[date]}[/math][/raw]
Find any previous date:   [raw]&lsFieldNamedatarq=[math]{[date]}[/math][/raw]
 
Dates ranging from 0-1 week ago:   [raw]&rnFieldNamedatarq=[math]{[date]}-7[/math],[math]{[date]}[/math][/raw]
Dates ranging from 1-2 weeks ago:   [raw]&rnFieldNamedatarq=[math]{[date]}-14[/math],[math]{[date]}-7[/math][/raw]
Dates from 0-1 week in the future:   [raw]&rnFieldNamedatarq=[math]{[date]}[/math],[math]{[date]}+7[/math][/raw]
Dates from 1-2 weeks in the future:   [raw]&rnFieldNamedatarq=[math]{[date]}+7[/math],[math]{[date]}+14[/math][/raw]
4 months ago thru 35 days in the future:   [raw]&rnFieldNamedatarq=[math]{[date]}-{04/00/0000}[/math],[math]{[date]}+{00/35/0000}[/math][/raw]
16 years 7 months ago thru today:   [raw]&rnFieldNamedatarq=[math]{[date]}-{07/00/0016}[/math],[math]{[date]}[/math][/raw]
 

 
Displaying dates in web pages:
 
A database field date (default format):   [raw][format days_to_date][FieldName][/format][/raw]   [format days_to_date][math]729855[/math][/format]
A db field date with a different format:   [raw][format days_to_date %d.%m.%Y][FieldName][/format][/raw]   [format days_to_date %d.%m.%Y][math]{[date]}[/math][/format]
 
One week earlier than a db field date:   [raw][format days_to_date][math][FieldName]-7[/math][/format][/raw]   [format days_to_date][math]729855-7[/math][/format]
One week later than a db field date:   [raw][format days_to_date][math][FieldName]+7[/math][/format][/raw]   [format days_to_date][math]729855+7[/math][/format]
 
Today's date (default format):   [raw][date][/raw]   [date]
Today's date in a different format:   [raw][date %d.%m.%Y][/raw]   [date %d.%m.%Y]
 
One week ago today:   [raw][math date]{[date]}-{00/07/0000}[/math][/raw]   [math date]{[date]}-{00/07/0000}[/math]
One month ago today:   [raw][math date]{[date]}-{01/00/0000}[/math][/raw]   [math date]{[date]}-{01/00/0000}[/math]
One year ago today:   [raw][math date]{[date]}-{00/00/0001}[/math][/raw]   [math date]{[date]}-{00/00/0001}[/math]
 
One week in the future:   [raw][math date]{[date]}+{00/07/0000}[/math][/raw]   [math date]{[date]}+{00/07/0000}[/math]
One month in the future:   [raw][math date]{[date]}+{01/00/0000}[/math][/raw]   [math date]{[date]}+{01/00/0000}[/math]
One year in the future:   [raw][math date]{[date]}+{00/00/0001}[/math][/raw]   [math date]{[date]}+{00/00/0001}[/math]
 


These guidelines are provided free of charge courtesy of WebDNA Solutions.


Kenneth Grome

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:

Email Spam a bit of Hell (2004) Mass Mail (2000) wow (1998) 6.0 /Panther install issues (2004) Sendmail truncation in Eudora Clients (1998) caching -check- (2001) [WebDNA] Delete founditems (2010) Commas in search (1998) [WebDNA] [append] does not add the newline char at the end of (2009) Dummy Credit Card Number for debug? (1997) A little syntax help (1997) feature request 4.5 or 5 (2001) RE: Price recalc based on quantity (1997) Catalogs and W* (1996) NT error logs (1997) CyberCash book/ship model (2000) [AppendFile] problem (WebCat2b13 Mac .acgi) (1997) [WebDNA] SpeedTest (2009) Error Lob.db records error message not name (1997) More questions about serial number dishing (1997)