Brian B. Burton's Guide WebCatalog
WebDNA Basics Advanced Topics OnSite Training WebCat Rants & Raves Other WebCatalog Links Site Feedback    



When [date] isn't the date. -OR - Damn it, why isn't my date showing up right!
We've all done it, and it's been documented back to about 1997, but every new WebDNA programmer encounters it, and posts to the WebTalk list when it happens, so here's a quick explaination of what's going on.

WebCatalog has a tag [date] that you like to use. It's a pretty handy tag. Imagine this, you put [date] in your webpage, and you get today's date. You can even change how the date looks, simply by mucking up the tag thusly: [date %Z%a%p].

Here's the bad news, in the shopping cart file, there is a field called (can you see this coming, or what?) DATE. This "date" field superseeds the "date" field that the system generates. However, you only have access to the shopping cart "date" field inside shopping cart related pages. These pages either are served up by a preceeding page with a command* of add/purchase/remove/showcart, or from inside an [orderfile] context.

More bad news, if you have a database with a field named "date", wanna guess which "date" gets shown inside a [founditems] loop? Ok, that one makes sense, until you need to embed a nested [append] or [replace] with today's date inside that nice [founditems] loop.

OK, so how do you know if you're getting the wrong day? well, the first giveaway is that your formatting of the date tag isn't working correctly (you get output like 9/21/01 %a %b %d,%Y] instead of Fri Sept 21 2001 ) If this is the case, you're using a "date" field instead of the system "date" tag. Look around, are you inside a [founditems] loop? Or an orderfile context? If not, then most likely the page before has a <input type=hidden name=command value=showcart> Everytime I have to help someone with this, it is always the "showcart" command that is causing the problem!

What can you do to prevent this? Well, if you need today's date, you can store it (formatted anyway you want) in a text field and pass it along between pages. You can also do this at the top of a page (with a [orderfile] or [founditems] below this code)
[text show=f]myday=[date %a %b %d,%Y][/text]

If you INSIST on using a showcart function, and still need to format today's date, then you have to add
<input type="hidden" name="myday" value="[url][date %a %b %d,%Y][/url]"> on the same page that has the evil showcart command.] You can then use the "myday" variable as needed on the next page.

One other idea for either of the above cases is to set today's date as a number [math]myday={[date]}[/math], and then format it any way you want to when you go to use it: [Format Days_To_Date %m/%d/%Y][myday][/format]. This gives you some flexibility.

 

*If you are using commands, you deserve all the bad things that happen to you. Shame on you! If you use contexts, they leave you tingly, spring fresh and full of zing!
(the mfg. claims you'll also get clean manageable hair, but you may have to rinse and repeat for best results.)


HOME | Basics | Advanced | Training | Rants+Raves | Links | Feedback
This whole page, and everything on it ©2001 Brian B. Burton. This page and the text contained herein may not be reproduced on any other site, or via any other means. Really, how hard is it just to link to this site, so people get to see the latest updates? http://www.burtons.com/webdna/   Thank You.

Site design by Clint Davis. Thank You Clint!