Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

get the half of the year (like quarter)

$
0
0

Hi guys,

 

I need to get the "half" of the year.

 

I am using the following...

Case

When

CAST(DATEPART(quarter, Stock.VALUEDATE)asint)= 1 then'1'

When

CAST(DATEPART(quarter, Stock.VALUEDATE)asint)= 2 then'1'

When

CAST(DATEPART(quarter, Stock.VALUEDATE)asint)= 3 then'2'

When

CAST(DATEPART(quarter, Stock.VALUEDATE)asint)= 4 then'2'

Else

'UnKnown'

End

AS'Half',

 

Is there any more elegant solution?  something like

 

DATEPART

(half,Stock.ValueDate)AS'Month'

 

Thanks.

 


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>