Link to home
Start Free TrialLog in
Avatar of cheryl9063
cheryl9063Flag for United States of America

asked on

SQL date syntax

How do I create this 08,2012?.. The month has to be 2 digits
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

-- Here's two ways to do the the month with a leading zero
Declare @dt datetime = GETDATE()

SELECT 'Month with a leading zero', CONVERT(VARCHAR(2), @dt,101), RIGHT('0' + CAST(Month(@dt) as varchar(2)), 2)

Are you trying to return MM{comma}YYYY?
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the grade.  Good luck with your project.  -Jim