www.webdeveloper.com
Results 1 to 3 of 3

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

  1. #1
    Join Date
    Mar 2011
    Posts
    39

    How to multiply a variable value with a fixed value ?

    hello

    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
    Location
    Ankh-Morpork
    Posts
    19,530
    Something like this, maybe?
    Code:
    SELECT DATEDIFF(`expiry_date`,NOW()) * 0.25 AS days FROM `tab_subscriptions` WHERE `user_id` = '[user_id]';
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Mar 2011
    Posts
    39
    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



Recent Articles