Login    Forum    Search    FAQ   Blog

Board index » Server Side Development » SQL




 Page 1 of 1 [ 4 posts ] 



Author Message
 Post subject: Case statement issue
 Post Posted: Tue Nov 10, 2009 8:48 pm 
Offline

Joined: Sat Feb 21, 2009 1:13 pm
Posts: 63
Hello!!!! every one ,
I was using dis query

Code:
SELECT
CASE WHEN DATEDIFF(MONTH, '2009-01-10','2010-10-01') > 1 THEN 'GREATER THAN 12 MONTHS'
ELSE DATEDIFF(MONTH,'2009-01-10','2010-10-01') END AS 'Age in TES',
CASE WHEN DATEDIFF(MONTH,'2009-01-10','2010-10-01') > 1 THEN 'GREATER THAN 12 MONTHS'
ELSE DATEDIFF(MONTH,'2009-01-10','2010-10-01') END AS 'Age Since Service Date'

however i was gettin te error "Conversion failed wen convertin the varchar
value 'GREATER THAN 12 MONTHS' to data type int."

Pls help


Top 
 Post subject: Re: Case statement issue
 Post Posted: Tue Nov 10, 2009 8:48 pm 
Offline

Joined: Sat Feb 21, 2009 11:06 am
Posts: 1794
Code:
SELECT
CASE WHEN DATEDIFF(MONTH, '2009-01-10','2010-10-01') > 1 THEN 'GREATER THAN 12 MONTHS'
ELSE cast(DATEDIFF(MONTH,'2009-01-10','2010-10-01') as varchar(10)) END AS 'Age in TES',
CASE WHEN DATEDIFF(MONTH,'2009-01-10','2010-10-01') > 1 THEN 'GREATER THAN 12 MONTHS'
ELSE cast(DATEDIFF(MONTH,'2009-01-10','2010-10-01') as varchar(10)) END AS 'Age Since Service Date'


Top 
 Post subject: Re: Case statement issue
 Post Posted: Tue Nov 10, 2009 8:48 pm 
Offline

Joined: Sat Feb 21, 2009 1:13 pm
Posts: 63
Thanks a lot


Top 
 Post subject: Re: Case statement issue
 Post Posted: Tue Nov 10, 2009 8:49 pm 
Offline

Joined: Sat Feb 21, 2009 11:06 am
Posts: 1794
Note da change I made. All da values should be same in data type


Top 
Display posts from previous:  Sort by  
 
 Page 1 of 1 [ 4 posts ] 




Board index » Server Side Development » SQL


Who is online

Users browsing this forum: No registered users and 1 guest

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron