TODATETIMEOFFSET inside a case expression
I am trying to make the TODATETIMEOFFSET work inside a case expression. when I try to do this SQL returns me following error. works fine if it's not inside a case expression. What am I doing wrong?
SELECT AP.POR,
AP.POD Path,
TODATETIMEOFFSET(AP.StartTime, '-06:00') as StartTime,
MinimumPrice = (
CASE WHEN ( CHARINDEX('','' + '''+@Provider+''' + '','', '','' + '''+@UserCompanyList+''' + '','') > 0 )
THEN TODATETIMEOFFSET(AP.MinimumPrice, '-06:00')
ELSE ( (
CASE WHEN (getdate() < C.ClearingTime and C.OpenPriceMask = 0)
THEN NULL
WHEN (getdate() > C.ClearingTime and C.ClearedPriceMask = 0)
THEN NULL
ELSE AP.MinimumPrice
END
) )
END
),
AP.ClearingPrice,
AP.PriceUnits
FROM TES_Auction C
INNER JOIN TES_AuctionPrice AP ON AP.AuctionID = C.ID
Msg 206, Level 16, State 2, Line 1
Operand type clash: decimal is incompatible with datetime2
also how can I make 'as' syntax work inside a case expression?