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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting date to format mm/yyyy 1

Status
Not open for further replies.

MattSmithProg

Programmer
Sep 9, 2001
76
AU
Hi,

I am attempting to convert a datetime column to the format mm/yyyy. At present I have this

SELECT

CAST(Month(getDate()) AS CHAR(2)) + "/" + CAST(YEAR(getDate()) AS CHAR(4))

However this returns 8/2002 but I want 08/2002. Is there any way to get the month to return a zero at the start if the current month is only a single integer?

Thanks for your help Matt Smith

No two nulls are the same
 
Thanks Terry

I wouold give you a star but my browser does not support scripting. Matt Smith

No two nulls are the same
 
OOOPPPPSSSS, I meant to add because I was able to use the solution also.

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top