Jump to content


Photo

help with mysql queries and dates...


  • Please log in to reply
7 replies to this topic

#1 acidglitter

acidglitter
  • Members
  • PipPipPip
  • Advanced Member
  • 355 posts

Posted 18 July 2006 - 08:08 PM

How can I only show things from a table that are at least one month old? The row or whatever that shows the dates is the "date" type
my makeup site <3
http://vanillaeyeliner.com

#2 willfitch

willfitch
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts
  • LocationNew Hope, PA

Posted 18 July 2006 - 08:09 PM

SELECT * FROM table WHERE date_field > CURDATE()
Zend Certified Engineer (ZEND001989)
www.willfitch.com

#3 acidglitter

acidglitter
  • Members
  • PipPipPip
  • Advanced Member
  • 355 posts

Posted 19 July 2006 - 05:22 AM

hmm I tried that but it didn't work :(
my makeup site <3
http://vanillaeyeliner.com

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 19 July 2006 - 05:44 AM

SELECT something FROM tbl_name WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY)

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 acidglitter

acidglitter
  • Members
  • PipPipPip
  • Advanced Member
  • 355 posts

Posted 15 August 2006 - 03:21 AM

So I tried that and I changed everything except for
WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY)

Instead of limiting what it showed to things that are at least a month old, it just showed EvEryThiNG :(
my makeup site <3
http://vanillaeyeliner.com

#6 acidglitter

acidglitter
  • Members
  • PipPipPip
  • Advanced Member
  • 355 posts

Posted 17 August 2006 - 11:55 PM

*bump*
my makeup site <3
http://vanillaeyeliner.com

#7 HeyRay2

HeyRay2
  • Members
  • PipPipPip
  • Advanced Member
  • 223 posts

Posted 18 August 2006 - 12:05 AM

redarrow's example, from MySQL.org, is missing a comparison. Otherwise, it should work fine. Try this:

<?php

$query = "SELECT something FROM tbl_name WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= date_col";

?>


#8 acidglitter

acidglitter
  • Members
  • PipPipPip
  • Advanced Member
  • 355 posts

Posted 16 September 2006 - 05:41 AM

gr this is irritating..

So it looks like this now
$sql=mysql_query("SELECT * FROM losers WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= lastused");

Maybe I should just select everything and then put LIMIT TO something..?
my makeup site <3
http://vanillaeyeliner.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users