Results 1 to 3 of 3

Thread: How to multiply a variable value with a fixed value ?

  1. #1
    Join Date
    Mar 2011

    How to multiply a variable value with a fixed value ?


    I have this query:

    SELECT DATEDIFF(`expiry_date`,NOW()) AS days FROM `tab_subscriptions` WHERE `user_id` = '[user_id]';

    This allow me to get the remaining day before end of user subscription. Now I would like multiply the remaining day by the fixed value 0.25. So in practice if 300 days remain X 0.25, the query must return 75.

    Somebody can tell me the correct syntax ?? I don't see how to do my calculation in the code...
    thank in advance for your time
    Last edited by dotcom22; 02-12-2014 at 01:37 PM.

  2. #2
    Join Date
    Aug 2004
    Something like this, maybe?
    SELECT DATEDIFF(`expiry_date`,NOW()) * 0.25 AS days FROM `tab_subscriptions` WHERE `user_id` = '[user_id]';
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Join Date
    Mar 2011
    You rock you made my day !!!

    I did not think it was as simple and your solution work as expected.

    Many thank and all the best to you

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center