How to search month wise data from Sql Server [Resolved]

Posted by Naseer under Sql Server on 8/28/2016 | Points: 10 | Views : 1339 | Status : [Member] | Replies : 1
Hi Friends,

How to search month wise data from Sql Server:

In DB data is in the form of dd-mm-yy (ex: 05-10-1989)

I need to get the data based on month , My problem is datatype is nvarchar(50), I can't able to get the date based on month directly.

Thanks in Advance,

Thanks,
Naseer




Responses

Posted by: Rajnilari2015 on: 8/28/2016 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
Try this to get month

declare @dt as nvarchar(50) = '05-10-1989'

select [Month] = parsename(replace(@dt,'-','.'),2)


output
---------

Month
10


Now I hope you can proceed.

Thanks.

--
Thanks & Regards,
RNA Team

Naseer, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response