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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to add a case checking month no using sysdate
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cplusplus
Aged Yak Warrior

567 Posts

Posted - 02/08/2013 :  12:02:08  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
6065 Posts

Posted - 02/08/2013 :  15:53:38  Show Profile  Reply with Quote
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

Edited by - TG on 02/08/2013 15:56:03
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000