Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2006
    Location
    My family and I live in Brighton, England
    Posts
    982
    Plugin Contributions
    0

    Default SQL: Rounding Up All prices to nearest pound

    I have a multiple-currency site. I've just physically transferred from a Euro country to the UK. I successfully used the following sql to update my site prices according to the current exchange rate at that time:

    Code:
    update products set products_price = products_price * '0.83870798';
    However, my default currency prices are now a bit messy, i.e. £3.61 or £4.39 (I probably should have used 0.85 instead of 0.83870798 in the sql). Is it possible to use a similar sql to round up all of the default currency prices to the nearest pound?

    Thanks!!

  2. #2
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: SQL: Rounding Up All prices to nearest pound

    I think that:

    update products set products_price = ROUND(products_price);

    should do it but it is untested. Copy your database and try it on the copy first :-)

    otherwise have a look at:

    http://dev.mysql.com/doc/refman/5.0/...functions.html

    (re-reading your post you probably want to use ceiling rather than round)

  3. #3
    Join Date
    Jun 2006
    Location
    My family and I live in Brighton, England
    Posts
    982
    Plugin Contributions
    0

    Default Re: SQL: Rounding Up All prices to nearest pound

    Quote Originally Posted by niccol View Post
    I think that:

    update products set products_price = ROUND(products_price);

    should do it but it is untested. Copy your database and try it on the copy first :-)

    otherwise have a look at:

    http://dev.mysql.com/doc/refman/5.0/...functions.html

    (re-reading your post you probably want to use ceiling rather than round)
    Perfect. Thanks for that, it was EXACTLY what I was looking for. Taking your advice, I used:

    HTML Code:
    update products set products_price = CEILING(products_price);
    I successfully introduced it into a number of Zen Carts and the following versions: 1.3.6 & 1.3.8a.

    Thank again :)

 

 

Similar Threads

  1. Europe : rounding tax to nearest .5 cents (eliminate pennies)
    By nan in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 15
    Last Post: 1 Sep 2017, 09:12 AM
  2. Round prices to nearest dollar.
    By bestbridalprices in forum General Questions
    Replies: 2
    Last Post: 7 Oct 2010, 04:12 PM
  3. Can I round prices to the nearest 5 cents?
    By xeontranq in forum General Questions
    Replies: 0
    Last Post: 3 May 2010, 04:47 AM
  4. SQL for changing all products' prices?
    By dinki in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 18 Jun 2009, 06:31 PM
  5. SQl Command to update all prices in bulk
    By ksmglobal in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 3 Apr 2008, 03:34 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR