Jump to content

Date Time SQL query


aarbrouk

Recommended Posts

Hello,

 

I am trying to display the latest products that have been added in stock...

 

I have a "DateAdded" field in my products table...

 

Could someone tell me how I query the table to pull out the products that have been added a month between the "DateAdded" and the Current Date??

 

Help would be much appreciated

Link to comment
Share on other sites

What is the DATE_SUB??

 

so far I have:

 

"SELECT * FROM product WHERE product.ProductStatus='Active' AND product.DateAdded =DATE_SUB(curdate(), INTERVAL 1 MONTH) ORDER BY RAND() LIMIT 4";

 

 

This error comes up:

SELECT * FROM product WHERE product.ProductStatus='Active' AND product.DateAddedDATE_SUB(curdate(), INTERVAL 3 MONTH) ORDER BY RAND() LIMIT 4

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY RAND() LIMIT 4' at line 1

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.