I have a table like this:
submitDate field is set to smalldate type.
I want to retrieve only one record for all the records with the same year/month value. In other words, I want to get the 2013/10 for all the records that contain that part (2013/10) in the submitDate field.
Thanks for help.
Oh, I got it. This works.
select distinct datepart(mm,submitDate) as Months from myTable.
You may run into issue if you have multiple years data. Check this query out:
select datepart(mm,getdate()) , month(getdate()) , Convert(varchar(6),getdate(),112) , Convert(varchar(4),getdate(),12)