Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Tricky Date Range -> Article of Month

Quote Reply
Tricky Date Range -> Article of Month
I am attempting to do something similar that other Links SQL users have attempted with date ranges, but...I have modded Links SQL v.1.13 to store a table of articles that includes the following fields:

isFeatured (enum, N/Y) - N = No, Y = Yes
FeatureDate (Date)

Now, I am attempting to dynamically show featured articles for the month...I've seen a few Threads about "Sites of the Month", but the code hacks are configured differently.

The following query works fine:

Code:

SELECT *
FROM tbl_AG_Articles
WHERE isFeatured = 'Y' AND FeatureDate = '2001-02-01'


I am attempting to use a monthly range to replace the hard coded DATE.

Any suggestions would be greatly appreciated.

Thanks in advance.

Regards,

Eliot Lee
Quote Reply
Re: Tricky Date Range -> Article of Month In reply to
What about creating a select list for the featured date that you set, something like this:

Jan 2001
Feb 2001
Mar 2001
etc...

Cover for the next x years. You then use this in your link admin to modify the link's featured date.

Once set, modify your build to use today's date from your server and strip out the 'month' and 'year' portions. Once you've got those just run them through a 'check' to define the month, i.e.;

$thisyear = {strip year from $date}

if ($month eq '01') {$thismonth = "Jan"}
elsif ($month eq '02') {$thismonth = "Feb"}
etc...

$featureddate = ($thismonth & $thisyear)

Now use the $featureddate in your selection call:

----------------------
SELECT *
FROM tbl_AG_Articles
WHERE isFeatured = 'Y' AND FeatureDate = $featureddate
----------------------

Any good?


All the best
Shaun

Quote Reply
Re: Tricky Date Range -> Article of Month In reply to
Good ideas, qango...except with this particular modded application of LINKS SQL, I am not going to be relying on the BUILD script. I am trying to dynamically update values within the Articles table. So, the build option would not work...

But your ideas for checking the date within the featured.cgi script are good and I will give them a shot.

Thanks for your reply...I appreciate it. (I will let you know what I come up with and post my solution in this thread for other LINKS SQL v.1.X users.)

Regards,

Eliot Lee
Quote Reply
Re: Tricky Date Range -> Article of Month In reply to
Very cool...I figured it out....

I am using the following codes:

Code:

SELECT *
FROM tbl_AG_Articles
WHERE isFeatured = 'Y' AND YEAR(FeatureDate) = YEAR(NOW()) AND MONTH(FeatureDate) = MONTH(NOW())


Guess, I'll spend more time at the MySQL web site.

But, thanks again, qango, for the reply.

Wink


Regards,

Eliot Lee