Re: Dates and Math - Simple Subtraction
This WebDNA talk-list message is from 2004
It keeps the original formatting.
numero = 58887
interpreted = N
texte = You cannot specify a format with the [math date] syntax.However, since your search specifies "SOLDtype=date", what WebDNA does internally is convert your parameter from a date to a number AND the SOLD value from every record in your database from a date to a number, then compares them as numbers. So, WebDNA will be comparing numbers to numbers as long as it understands the human-readable dates provided, which it does in your case.Note that this is one reason many WebDNA developers choose to store dates in their databases as [math]{[date]}[/math] values, rather than as human-readable dates. Searches are faster because WebDNA doesn't need to convert the dates to numbers.- brianOn Jul 26, 2004, at 3:30 PM, David Cate wrote:> Oh yes! I saw that before I sent it, but still didn't work.>> I do like the simple step, but what if I'm searching for a six > character date? 00/00/00>> Can I use the format with the [math date]> i.e. [math date format=%m/%d/%y]>> Thanks for taking time out with a hack to help...>> David>> On Jul 26, 2004, at 5:58 PM, Brian Fries wrote:>>> I step 3), you use a variable named [THREEWEEK] - your previous steps >> created the [TWOWEEK] variable.>>>> You should be able to simplify this into one easy step:>>>> [text]SOLDDATE=[math date]{[date]}-14[/math][/text]>>>> The {[date]} results in a number (days since the year 0000), from >> which you can simply subtract 14 days.>>>> The [math date] turns that number back into a human-formatted date >> (using you preferences settings).>>>> - brian>>>> On Jul 26, 2004, at 2:12 PM, David Cate wrote:>>>>> Hello,>>>>>> I'm trying to only show records that exist within the past two >>> weeks. If an item was sold more than two weeks ago, we don't want to >>> display the record.>>>>>> Can someone tell me where I've gone wrong?>>>>>> 1. Define [TODAY[>>> [text]TODAY=[date %m/%d/%y][/text]>>> (Note: Database already carries 00/00/00 value) - Number turns out >>> fine>>>>>> 2. Define two week value>>> [text]TWOWEEK=[Math]{[TODAY]}-{00/14/00}[/Math][/text]>>> (This seems to be the problem - This turns out a number 34870 - not >>> sure how that happened.>>>>>> 3. Format TWO WEEK to var [SOLDDATE]>>> [text]SOLDDATE=[format days_to_date >>> %m/%d/%y][THREEWEEK][/format][/text]>>> (value turns out 00/00/00)>>>>>> Here's the search query...which obviously does not work. Anyone have >>> any suggestions for anything for me look at?>>> [search >>> db=admin/cars- >>> n.db&geSTOCKdata=[blank]&geSolddata=[SOLDDATE]&SOLDtype=date]>>>>>> Thanks in advance.>>>>> -- Brian Fries, BrainScan Software -- >> http://www.brainscansoftware.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:
You cannot specify a format with the [math date] syntax.However, since your search specifies "SOLDtype=date", what WebDNA does internally is convert your parameter from a date to a number AND the SOLD value from every record in your database from a date to a number, then compares them as numbers. So, WebDNA will be comparing numbers to numbers as long as it understands the human-readable dates provided, which it does in your case.Note that this is one reason many WebDNA developers choose to store dates in their databases as [math]{[date]}[/math] values, rather than as human-readable dates. Searches are faster because WebDNA doesn't need to convert the dates to numbers.- brianOn Jul 26, 2004, at 3:30 PM, David Cate wrote:> Oh yes! I saw that before I sent it, but still didn't work.>> I do like the simple step, but what if I'm searching for a six > character date? 00/00/00>> Can I use the format with the [math date]> i.e. [math date format=%m/%d/%y]>> Thanks for taking time out with a hack to help...>> David>> On Jul 26, 2004, at 5:58 PM, Brian Fries wrote:>>> I step 3), you use a variable named [THREEWEEK] - your previous steps >> created the [TWOWEEK] variable.>>>> You should be able to simplify this into one easy step:>>>> [text]SOLDDATE=[math date]{[date]}-14[/math][/text]>>>> The {[date]} results in a number (days since the year 0000), from >> which you can simply subtract 14 days.>>>> The [math date] turns that number back into a human-formatted date >> (using you preferences settings).>>>> - brian>>>> On Jul 26, 2004, at 2:12 PM, David Cate wrote:>>>>> Hello,>>>>>> I'm trying to only show records that exist within the past two >>> weeks. If an item was sold more than two weeks ago, we don't want to >>> display the record.>>>>>> Can someone tell me where I've gone wrong?>>>>>> 1. Define [TODAY[>>> [text]TODAY=[date %m/%d/%y][/text]>>> (Note: Database already carries 00/00/00 value) - Number turns out >>> fine>>>>>> 2. Define two week value>>> [text]TWOWEEK=[math]{[TODAY]}-{00/14/00}[/Math][/text]>>> (This seems to be the problem - This turns out a number 34870 - not >>> sure how that happened.>>>>>> 3. Format TWO WEEK to var [SOLDDATE]>>> [text]SOLDDATE=[format days_to_date >>> %m/%d/%y][THREEWEEK][/format][/text]>>> (value turns out 00/00/00)>>>>>> Here's the search query...which obviously does not work. Anyone have >>> any suggestions for anything for me look at?>>> [search >>> db=admin/cars- >>> n.db&geSTOCKdata=[blank]&geSolddata=[SOLDDATE]&SOLDtype=date]>>>>>> Thanks in advance.>>>>> -- Brian Fries, BrainScan Software -- >> http://www.brainscansoftware.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/
Brian Fries
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:
[searchString] (1997)
Major Security Hole (1998)
DOS variable bug (was SandBox and ImageMagick) (2003)
Setting up WebCatalog with Retail Pro data (1996)
WC2b15 - [HTMLx]...[/HTMLx] problems (1997)
append db weirdness (1999)
Changing price for a SLU based on options (size, etc.) (1997)
Feature Request: ! character bug correct in [showif[variable]=] (2000)
How many lookups does it take ... (2003)
Viewing Changes (1998)
Nested tags count question (1997)
Weird problems with [SHOWIF]s (1997)
anyone have an automated template encrypter? (2000)
[WebDNA] Cookie behavior (2010)
Stopping bad HTML propagation ? (1997)
PCS Frames (1997)
Upgrade to web DNA6.0 (2004)
Mass download. (2003)
Grep email addresses in bbedit or webdna ... (2003)
Newbie problem blah blah blah (1997)