PHP MySQL Date Query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • elcob32
    New Member
    • Mar 2007
    • 3

    #1

    PHP MySQL Date Query

    Hey guys, I am no pro in PHP or MySQL, I usually develop in ASP / ASP.NET with SQL Server or Access.

    I have the following query, and I need to add a condition to the where clause to check if the date is less than 24 hours old. Any help would be greatly appreciated.
    [code=mysql]
    SELECT link_comments, link_author, link_status, link_randkey, link_category, link_date, link_votes, link_karma, link_published_ date FROM tblLinks WHERE link_id = $id[/code]

    Thanks
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Elcob. Welcome (back) to TSDN!

    You posted this in the Articles section. I'll go ahead and move it to the Forum where an Expert will be more likely to find it.

    Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.

    You'll be wanting to do something like this:
    [code=mysql]
    SELECT
    `link_comments` ,
    `link_author`,
    `link_status`,
    `link_randkey`,
    `link_category` ,
    `link_date`,
    `link_votes`,
    `link_karma`,
    `link_published _date`
    FROM
    `tblLinks`
    WHERE
    (
    `link_id` = '$id'
    AND
    `link_date` > DATE_SUB(NOW(), INTERVAL 1 DAY)
    )
    [/code]

    Comment

    • elcob32
      New Member
      • Mar 2007
      • 3

      #3
      Sorry,

      I'll be sure to keep that in mind in the future. This was very helpful. Thanks

      Comment

      Working...