www.webdeveloper.com
Results 1 to 3 of 3

Thread: EASY IF THEN statement help

  1. #1
    Join Date
    Aug 2005
    Posts
    12

    Smile EASY IF THEN statement help

    Ok, I've been having this crazy problem that sounds simple, but when you put it through testing. It all looks good until that one scenario destroys the whole code.

    What I'm trying to do is develop and IF STATEMENT that meets this criteria:

    Interval
    sale1
    sale2
    sale3

    Start Date
    11-1-05
    12-2-05
    12-23-05

    End Date
    12-1-05
    12-31-05
    12-31-05

    Price
    10
    20
    30

    count
    101
    0
    0

    Max
    101
    102
    103

    with the above value the
    currentprice = 20

    As you can see I have 3 different sale intervals with different starting dates.
    Each interval also has a max count. Once the max has been reached the price goes up one level disregarding the starting date of the next level.
    Code:
    This is what I have so far to measure for dates
    
    currentdate = now()
    
    IF currentdate > date1 THEN
    currentprice = 10
    
    	IF currentdate > date2 THEN
    	currentprice = 20
    	
    		IF currentdate > date3 THEN
    		currentprice = 30
    		END IF
    		
    	END IF
    	
    END IF
    
    This is what I have so far to measure for count/max.
    
    
    IF count1 < max1 THEN
    currentprice = 10
    
    	IF count2 < max2 THEN
    	currentprice = 20
    	
    		IF count3 < max3 THEN
    		currentprice = 30
    		END IF
    		
    	END IF
    	
    END IF
    
    They both work independently.
    
    (((I just don't know how to combine the two correctly.)))
    Any IDEAS appreciated.

  2. #2
    Ubik's Avatar
    Ubik is offline &lt;%= &quot;New Meja Hor&quot; %&gt;
    Join Date
    Nov 2005
    Location
    Earth
    Posts
    361
    if you are pulling this from a database, it might be easier to do this using the SQL rather than the server side script.

    Are you pulling the sales prices, amounts and dates from a database?

  3. #3
    Join Date
    Jun 2003
    Location
    Indiana, USA
    Posts
    1,138
    Code:
    IF currentdate > date1 OR count1 < max1 THEN
    currentprice = 10
    
    ELSEIF currentdate > date2 OR count2 < max2 THEN
    currentprice = 20
    	
    ELSEIF currentdate > date3 OR count3 < max3 THEN
    currentprice = 30
    
    END IF
    Change the OR to AND if you want both operations to be true.

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