Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trimming a data field

Status
Not open for further replies.

renee35

MIS
Jan 30, 2007
199
0
0
I have the below formula:

CONVERT(varchar(10), m.DOB, 101) that returns:

12/23/2008, how can I get it to return only 12/2008?

Thanks!

Thanks a bunch!!

-T
 
There is no CONVERT style for that. You will have to do it manually. Try this:
Code:
CONVERT(Month(m.DOB), varchar(2))+'/'+CONVERT(Year(m.DOB), char(4))

--John [rainbow]
-----------------------------------
Behold! As a wild ass in the desert
go forth I to do my work.
--Gurnie Hallock (Dune)
 
Thanks! I had to rearrange it like this in order to get it to work,

Convert(VarChar(2),Month(m.DOB))+'/'+Convert(VarChar(4), Year(m.DOB))

Thanks a bunch!!

-T
 
Sorry about that. I wrote them as CASTs, then decided to change to CONVERTs mid-post. Glad you figured it.

--John [rainbow]
-----------------------------------
Behold! As a wild ass in the desert
go forth I to do my work.
--Gurnie Hallock (Dune)
 
Alternatively ...

Code:
SELECT Right(Convert(varchar(10), m.DOB, 103), 7)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top