This week, “G.” in Burnett, TX, writes:
Dear Feed Doctor,
I’m having a week-long promotion the first week of September. Can I write a business rule that will automatically add promotional text to my feeds that week?
The answer is: “yes, but it’s not pretty.”
The GETCURRENTDATE Function
I’ve been trying to keep these posts short, but it’s more fun to give people the long story, so bear with me. Most of the time a Shopping Engine’s data feed has a single line at the top of the feed called a header, and the header usually is just a list of the names of the fields in the feed. I know; big news flash, right? Sometimes, though, an engine’s header is more complicated, and it may contain things like date and time that the feed was generated. And in keeping with the grand tradition of comparison shopping, no two engines want the date/time formatted the same way. To support this, we came up with a function called GETCURRENTDATE. The good news for G. is that she can use it, too.
GETCURRENTDATE has only a single input; it’s a text value that tells the function how to format the date and time. This is sometimes called a format string. This is just a series of code letters; each letter represents a digit of the date or time:
- yy: 2-digit year
- yyyy: 4-digit year
- MM: 2-digit month
- dd: 2-digit day
- hh: 2-digit hour
- tt: AM or PM
- HH: 2-digit hour (24-hour system)
- mm: 2-digit minute
You can combine these with separators, such as dashes, colons, or slashes, and you MUST put quotation marks around the whole thing. For example:
GETCURRENTDATE("yyyy/MM/dd")
I just used that in a feed, and here’s what I got:
2007/08/14
Nice Digression, But…
Right, now what about the original question: how can we write a rule that “turns on” at a certain day and “turns off” again on another day? Well, here’s where it’s not pretty: you can treat the output of GETCURRENTDATE as a number, and compare it to two different numbers that represent your start and end dates. Now, there is certainly more than one way to do this, but here’s what I suggest for G’s case: think of the start date as 20070901 and the end date as 20070907. Now she just needs to write the following rule:
IF(GETCURRENTDATE("yyyyMMdd")>=20070901 AND GETCURRENTDATE("yyyyMMdd")<=20070907,"Item on Sale","")
What this rule does is look at the current date; if it is between Sep. 1 and Sep. 7, then the “then” part of the IF is returned; otherwise, the “else” part is returned. Note that I left that blank; this assumes that G’s feed normally has no promo text. She could, of course, have some inventory field that is her normal promo text. If that’s the case, she could change the rule to be:
IF(GETCURRENTDATE("yyyyMMdd")>=20070901 AND GETCURRENTDATE("yyyyMMdd"),<=20070907,"Item on Sale",$somefield)
All right, that’s all for this edition. See you next week!

Amazon has 
