- Moderator
- #1
Here's a silly question... but for some reason I'm having a problem wrapping my brain around it.
We have products. Those products can be featured. Products are featured for a date range.
For example, halloween products are featured from October 15 to November 7th.
Every year, regardless of the year.
My database has a boolean called "Featured", and I run a routine nightly that goes through the products, looks at the featured date range, and sets the bit for whether or not that product is featured.
I have this working, but not the way I would like. Here is the issue.
I can't just use a date range, because it's recurring... in other words, I'm ignoring the year on the range... so the date range may be 10/15/2010 to 11/7/2010. I only care about the month and date.
Where I run into a *real* problem is when the featured dates cross the new year boundary... in other words, a new years product may run from 12/15 through 1/15
The dates are in two fields, "FeatureStartDate" and "FeatureEndDate", which are datetime fields in my SQL table.
I need to figure out the math so that it looks at the start and end dates, and figures out if "today" is within those dates. I can't just do >= StartDate OR <= EndDate, because that doesn't work on the new years' scenario shown above.
It gets especially tricky since I'm working with just the month and day. If I replace the year on the start and end dates with "this" year, then my routine doesn't work if we're coming up on the new year.
So, to summarize (I know, I ramble... sorry... I do it so that people completely understand what I'm asking...)
I have a product with a start and an end date.
That start and end date may bridge a year change.
I need to evaluate that start and end date, and determine if TODAY's date is within that start and end date.
It needs to be not dependent on a year; just the month and day.
If the condition is true, set a bit for that product marking it as "Featured"
Any thoughts on this tricky little bit of math?
TIA!
--Greg
Just my 2¢
"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."
--Greg
We have products. Those products can be featured. Products are featured for a date range.
For example, halloween products are featured from October 15 to November 7th.
Every year, regardless of the year.
My database has a boolean called "Featured", and I run a routine nightly that goes through the products, looks at the featured date range, and sets the bit for whether or not that product is featured.
I have this working, but not the way I would like. Here is the issue.
I can't just use a date range, because it's recurring... in other words, I'm ignoring the year on the range... so the date range may be 10/15/2010 to 11/7/2010. I only care about the month and date.
Where I run into a *real* problem is when the featured dates cross the new year boundary... in other words, a new years product may run from 12/15 through 1/15
The dates are in two fields, "FeatureStartDate" and "FeatureEndDate", which are datetime fields in my SQL table.
I need to figure out the math so that it looks at the start and end dates, and figures out if "today" is within those dates. I can't just do >= StartDate OR <= EndDate, because that doesn't work on the new years' scenario shown above.
It gets especially tricky since I'm working with just the month and day. If I replace the year on the start and end dates with "this" year, then my routine doesn't work if we're coming up on the new year.
So, to summarize (I know, I ramble... sorry... I do it so that people completely understand what I'm asking...)
I have a product with a start and an end date.
That start and end date may bridge a year change.
I need to evaluate that start and end date, and determine if TODAY's date is within that start and end date.
It needs to be not dependent on a year; just the month and day.
If the condition is true, set a bit for that product marking it as "Featured"
Any thoughts on this tricky little bit of math?
TIA!
--Greg
Just my 2¢
"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."
--Greg