question

sarathkumartata avatar image
sarathkumartata asked

SQL Server Forums - How to calculate starsign(ex:sagittarius,tarus)

Hello Can any one help getting this one. I have two columns 1)date of birth 2)starsign(ex:tarus, gemini, sagittarius)like these. My question is if i enter the date of birth in the date of birth column. depending on that starsign column should be filled. can any one send me the sqlserver query for this. how can i solve it thanks
queryalgorithm
1 comment
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

In order to do this in a query, you either need to store the dates that define the star signs, or you need to hard code them into the query. I'd suggest storing them.
0 Likes 0 ·

1 Answer

· Write an Answer
Mark avatar image
Mark answered
I'm not going to do all of these for you, but here is how I would basically handle that: DECLARE @DOB datetime set @DOB = '02/20/2010' SELECT @DOB DOB, CASE WHEN (MONTH(@DOB) = 1 AND DAY(@DOB) >= 21) OR (MONTH(@DOB) = 2 AND DAY(@DOB) = 20) OR (MONTH(@DOB) = 3 AND DAY(@DOB)
2 comments
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

+1 but you won't see it becuase I used up my alotment today. +1 in spirit.
0 Likes 0 ·
Thank you Grant. We're only alloted 5 a day?
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.