Code Snippet
charge = case when datepart(hour, getdate())>=20 then 10 else 8 end
|||That covers it up to midnight. Most likely you will also want to continue past midnight up to some early morning time.
If so, then something like this: (building on phdiwakar's suggestion) to charge $10 between 8 PM and 6 AM
Code Snippet
Charge = CASEWHEN ( datepart( hour, getdate()) >= 20
OR datepart( hour, getdate()) <= 5
) THEN 10
ELSE 8
END
No comments:
Post a Comment