Microsoft SQL -- "ELSE IF" ?

Below #1 works.

How can I get the below #2 "ELSE IF" working ?
---------------------------------------------------------------------------
#1

UPDATE TIME_SCANNING
SET Status = 'STOP',
    TotalTime =
        CASE
        WHEN (DATEPART(HOUR, DateTime) < 11) OR
             (DATEPART(HOUR, DateTime) = 11 AND DATEPART(MINUTE, DateTime) < 15)
         THEN (cast(cast(datediff(minute, DateTime , '2013-08-26 15:30:00.000' )as decimal(30,4)) / 60 as decimal(30,2)) - .5)/ Qty
         ELSE
         cast(cast(datediff(minute, DateTime , '2013-08-26 15:30:00.000' )as decimal(30,4)) / 60 as decimal(30,2)) / Qty
        END
---------------------------------------------------------------------------
#2

UPDATE TIME_SCANNING
SET Status = 'STOP',
    TotalTime =
        CASE
        WHEN (DATEPART(HOUR, DateTime) < 11) OR
             (DATEPART(HOUR, DateTime) = 11 AND DATEPART(MINUTE, DateTime) < 15)
         THEN (cast(cast(datediff(minute, DateTime , '2013-08-26 15:30:00.000' )as decimal(30,4)) / 60 as decimal(30,2)) - .5)/ Qty
         ELSE IF (DATEPART(HOUR, DateTime) = 13)        
         cast(cast(datediff(minute, DateTime , '2013-08-26 15:30:00.000' )as decimal(30,4)) / 60 as decimal(30,2)) / Qty
         ELSE
           -- nothing
        END
finance_teacherAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
CASE
  WHEN x THEN y
  WHEN a THEN b   -- Just keep adding when..then blocks, and not else if within a case
  END
0
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
UPDATE TIME_SCANNING
SET Status = 'STOP',
    TotalTime = 
	CASE
	WHEN (DATEPART(HOUR, DateTime) < 11) OR (DATEPART(HOUR, DateTime) = 11 AND DATEPART(MINUTE, DateTime) < 15)
		THEN (cast(cast(datediff(minute, DateTime , '2013-08-26 15:30:00.000' )as decimal(30,4)) / 60 as decimal(30,2)) - .5)/ Qty
	WHEN (DATEPART(HOUR, DateTime) = 13)         
		THEN cast(cast(datediff(minute, DateTime , '2013-08-26 15:30:00.000' )as decimal(30,4)) / 60 as decimal(30,2)) / Qty
	END 

Open in new window

0
Scott PletcherSenior DBACommented:
UPDATE TIME_SCANNING
SET Status = 'STOP',
    TotalTime =
        CASE
        WHEN (DATEPART(HOUR, DateTime) < 11) OR
             (DATEPART(HOUR, DateTime) = 11 AND DATEPART(MINUTE, DateTime) < 15)
         THEN (cast(cast(datediff(minute, DateTime , '2013-08-26 15:30:00.000' )as decimal(30,4)) / 60 as decimal(30,2)) - .5)/ Qty
         WHEN (DATEPART(HOUR, DateTime) = 13)
         THEN cast(cast(datediff(minute, DateTime , '2013-08-26 15:30:00.000' )as decimal(30,4)) / 60 as decimal(30,2)) / Qty
         ELSE TotalTime --if "nothing" means no change to existing data (ELSE 0 if "nothing" means zero)
        END
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.