Zen Cart Logo
Forums / General Questions / How do I create an sql to change the products_date_added

How do I create an sql to change the products_date_added

Locked

Views: 1,661

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
17 Jan 2008, 2:21 AM
#1
wtashby avatar

wtashby

Totally Zenned

Join Date:
Feb 2006
Posts:
594
Plugin Contributions:
0

How do I create an sql to change the products_date_added

I want to do an sql to change the products_date_added field in mysql to a different date in order to "reset" my New Products. I update my products daily, my site is new, and I have every single product listed as new right now.

Can someone make a suggestion please?

Thanks

17 Jan 2008, 2:45 AM
#3
wtashby avatar

wtashby

Totally Zenned

Join Date:
Feb 2006
Posts:
594
Plugin Contributions:
0

Re: How do I create an sql to change the products_date_added

DrByte:

Perhaps you should shorten your window of "new"?
https://www.zen-cart.com/tutorials/index.php?article=3

No, that doesn't help at all. My question stands. I want an sql that will allow me to change the products_date_added field to whatever date I want, when ever I upload products. Currently, the lowest setting is 7 days. That isn't short enough.

17 Jan 2008, 2:55 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How do I create an sql to change the products_date_added

UPDATE products SET products_date_added = '2008-01-17 12:32:17' WHERE products_id =2;

Or to make 1 year old:

UPDATE products SET products_date_added = '2007-01-17 12:32:17' WHERE products_id =2;
17 Jan 2008, 3:06 AM
#5
wtashby avatar

wtashby

Totally Zenned

Join Date:
Feb 2006
Posts:
594
Plugin Contributions:
0

Re: How do I create an sql to change the products_date_added

Definately on the right track Ajeh! To narrow my question down a little bit more, how would I change the added dates from, say, '2008-01-15 12:32:17' to '2008-01-08 12:32:17' ?

Oh, and is the "WHERE products_id =2;" for a specific product? What about all products on a certain date?

Obviously, one would have to know that exact date and time the products were uploaded as the change From part.

An sql that would do that would perfectly answer my question.

Thanks

17 Jan 2008, 3:17 AM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: How do I create an sql to change the products_date_added

wtashby:

I update my products daily, my site is new, and I have every single product listed as new right now.

Can someone make a suggestion please?When you say "I update my products daily", what exactly do you mean by that?
Are all your daily updates "new" products?

Or is something you're doing to "update" your products causing them to be added as "new" when really they aren't?

And, yes, I understand the question you asked. What you haven't said clearly is "why" your problem exists. I'm wondering if something you're doing is causing unexpected results ... perhaps some product-import tool that's not operating correctly. A poorly-written or configured import tool that wipes all products before reloading the entire product database, and marks everything new, isn't doing you any favors.

And, if your "daily" updates are "new" products ... then why is "7 days" too large a window? If I'm coming along and shopping 4 days from when you 'add a new product' but you tricked it into thinking it was old, I'd never see it as new.

So, in short, I'm saying ... are you sure you're not jumping to a solution without properly understanding the full root problem first?

17 Jan 2008, 3:21 AM
#7
wtashby avatar

wtashby

Totally Zenned

Join Date:
Feb 2006
Posts:
594
Plugin Contributions:
0

Re: How do I create an sql to change the products_date_added

Thanks to Ajeh's suggestion, I modified the sql a little from > UPDATE products SET products_date_added = '2008-01-17 12:32:17' WHERE products_id =2;
to > UPDATE products SET products_date_added = '2008-01-08 12:32:17' WHERE products_date_added = '2008-01-12 00:01:08';

which worked perfectly.

Thanks Ajeh!

17 Jan 2008, 3:23 AM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How do I create an sql to change the products_date_added

Do you add all of your products at 1:08? Otherwise you will have issues ...

17 Jan 2008, 3:28 AM
#9
wtashby avatar

wtashby

Totally Zenned

Join Date:
Feb 2006
Posts:
594
Plugin Contributions:
0

Re: How do I create an sql to change the products_date_added

Ajeh:

Do you add all of your products at 1:08? Otherwise you will have issues ...

Of course not. You have to look in the mysql under products -> products_date_added to see the exact date and time of the origional upload (copy and paste works great). If you type in the wrong date or time, then, nothing changes. But, after trying it, it works perfectly.

But like I said, you have to be careful to get the origional date and time correct.

17 Jan 2008, 3:46 AM
#10
wtashby avatar

wtashby

Totally Zenned

Join Date:
Feb 2006
Posts:
594
Plugin Contributions:
0

Re: How do I create an sql to change the products_date_added

So, for anyone interested in knowing how to change your new product dates in order for them to age out of New Products sooner than the minimum 7 days, this method, inspired by Ajeh works very will.

First, you have to log into your database, navigate to products -> products_date_added, and look for the dates you want to change.

Then, make an sql statement like this:

UPDATE products SET products_date_added = '2008-01-08 12:32:17' WHERE products_date_added = '2008-01-12 00:01:08';

The red date of course would be the date you want to use, the royal blue date is the EXACT date of the product in your DB that you want to reset.

You can use the built in "Install SQL Patches" feature in admin - tools - Install SQL Patches. Put the code in the "Enter the query to be executed:" box, be sure to end with ;

Click Send, and Voila! The dates have changed!

Hope this helps somone else out there. It sure helped me.

24 Feb 2008, 6:45 PM
#11
mezx avatar

mezx

New Zenner

Join Date:
Feb 2008
Posts:
24
Plugin Contributions:
0

Re: How do I create an sql to change the products_date_added

I have to do exactly this---so i'm happy i found this string. But re:

"First, you have to log into your database, navigate to products -> products_date_added, and look for the dates you want to change."

How do I log into my database?

Thanks.