I'm trying to insert values into a Billing table. For the BillingAmount, I would like that to change depending on what time the guest checks out. If the guest checks out before noon, then I would like the BillingAmount to just be the QuotedRate multiplied by how many nights they stayed. If the guest checks out after 1:00PM, then I would like the a 50% surcharge to be added. For the check out time, I'm just using the current system time. Simply put, I'm trying to use an IF statement in an INSERT INTO query. However, I keep getting syntax errors around the IF statement. How would I format this to get rid of any syntax errors? Any help would be appreciated.
SET IDENTITY_INSERT Billing OFF
INSERT INTO Billing (FolioID, BillingCategoryID, BillingDescription, BillingAmount, BillingItemQty, BillingItemDate)
VALUES(24
, 1
, 'Room'
, IF(CAST(GETDATE() as time) < '12:00 PM')
SELECT QuotedRate * Nights AS "TotalLodging"
FROM Folio
ELSE IF(CAST(GETDATE() as time) > '1:00 PM')
SELECT (QuotedRate * Nights) + ((QuotedRate * Nights) * .50) AS "TotalLodging"
FROM Folio
, 1
, GETDATE());


CASE WHENstatement. But I think it is better if you do "logic" work in your business layer (.net) and usesql queryonly for saving/updating data