How to extract only mm/yyyy

I can't seem to figure this out.

I have the following select statement:

select expire_date AS EXPIREDATE

right now, it returns mm/dd/yyyy along with the time. How can I extract only mm/yyyy? Tried using both cast and convert, couldn't get this to work.
IUAATechAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cyberkiwiCommented:
substring(convert(varchar(8), expire_date, 103), 4,10)
cyberkiwiCommented:
Sorry, please use this
select substring(convert(varchar(20), getdate(), 103), 4, 7)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LowfatspreadCommented:
select  stuff(reverse(convert(char(6),expire_date,112)),3,0,'\') as mmyyyy
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

IUAATechAuthor Commented:
Ok. I have the following query.

select substring(convert(varchar(20), expire_date, 103), 4, 7) AS EXPIREDATE, member_type AS MEMBERTYPE, count(person_id) AS TOTAL
from memberships
where membership = 'M' AND expire_date >= @StartDate AND expire_date < DATEADD(dd, 1, @EndDate)
group by substring(convert(varchar(20), expire_date, 103), 4, 7), member_type
order by EXPIREDATE desc

Is this how I do a "group by" on the expire_date?

As for the "order by", the outcome is inconsistent.

I get 12/2009, then 3/2010, 2/2010 and 1/2010.

any suggestion?
IUAATechAuthor Commented:
nevermind. the following seems to work.

select substring(convert(varchar(20), expire_date, 103), 4, 7) AS EXPIREDATE, member_type AS MEMBERTYPE, count(person_id) AS TOTAL
from memberships
where membership = 'M' AND expire_date >= @StartDate AND expire_date < DATEADD(dd, 1, @EndDate)
group by expire_date, member_type
order by expire_date
LowfatspreadCommented:
thats because expire date is a string not a date now so that order is correct...

try

select substring(convert(char(20), expire_date, 103), 4, 7) AS EXPIREDATE, member_type AS MEMBERTYPE, count(person_id) AS TOTAL
from memberships
where membership = 'M' AND expire_date >= @StartDate AND expire_date < DATEADD(dd, 1, @EndDate)
group by substring(convert(char(20), expire_date, 103), 4, 7), member_type
order by convert(datetime,'01/'+ EXPIREDATE) desc
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.