Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to add a case checking month no using sysdate

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2013-02-08 : 12:02:08
Is it possible i want to add a case when on top to check if sysdate() month > 2 then go thru below calculation else put value 0.


SUM(LPAD (TO_CHAR (( (CR_Units_01 + DB_Units_01 + CR_Units_02 + DB_Units_02)/
(
CASE MOD('2013', 4)
WHEN 0 THEN (177.14 + 165.71 )
ELSE (177.14 + 160.00 )
END
)), 'FM99999999990.00'), 11))

AS Month2,



Thank you very much for the helpful info.

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2013-02-08 : 15:53:38
do you mean this?:

case
when datepart(month, getdate()) <= 2 then 0
else <your expression>
end

EDIT:
sysdate() is oracle, right? If you need oracle help try dbforums - This forum is MS Sql Server specific.

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -