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

DATE_ADD MySQL Function?

Quote Reply
DATE_ADD MySQL Function?
Okay...I am making progress with my forum script/add-on. I am trying to show posts in the last 24, 48, 72 hours...I've been playing around with the DATE_ADD MySQL function, which is referenced here:

http://www.mysql.com/..._time_functions.html

(Although the examples given in this page are not that great since they simply use the SELECT statement within a table, which does not include JOINS or FROM.)

I am using the following codes in my forum script:

In Reply To:

my $postdays = $in->param('newposts');
if ($postdays = '24') {
$sth = $FORUMPOSTSDB->prepare ("SELECT * FROM Forum_Posts WHERE DATE_ADD(Add_Post, INTERVAL 1 DAY)");
}
elsif ($postdays = '48') {
$sth = $FORUMPOSTSDB->prepare ("SELECT * FROM Forum_Posts WHERE DATE_ADD(Add_Post, INTERVAL 2 DAY)");
}
elsif ($postdays = '72') {
$sth = $FORUMPOSTSDB->prepare ("SELECT * FROM Forum_Posts WHERE DATE_ADD(Add_Post, INTERVAL 3 DAY)");
}
else {
$sth = $FORUMPOSTSDB->prepare ("SELECT * FROM Forum_Posts WHERE DATE_ADD(Add_Post, INTERVAL 1 DAY)");
}


I have also tried using the MySQL example of "-1, $postdays", before the INTERVAL attribute.

But no matter what parameter value I add, like 144 or any other integer/numerical value, all posts show up.

Any ideas or directions would be helpful!

Thanks in advance! Wink

Regards,

Regards,

Eliot Lee
Subject Author Views Date
Thread DATE_ADD MySQL Function? Stealth 5919 Jul 13, 2001, 9:06 PM
Thread Re: DATE_ADD MySQL Function?
Alex 5822 Jul 16, 2001, 11:54 AM
Thread Re: DATE_ADD MySQL Function?
Stealth 5814 Jul 16, 2001, 8:00 PM
Thread Re: DATE_ADD MySQL Function?
Alex 5814 Jul 16, 2001, 11:00 PM
Thread Re: DATE_ADD MySQL Function?
tom_lee 5808 Jul 17, 2001, 7:13 AM
Post Re: DATE_ADD MySQL Function?
Stealth 5787 Jul 17, 2001, 5:47 PM