February 7, 2014 at 9:32 am
Hi
I found this to convert at date
cast(cast(sq.QuotaDate as date) as varchar(7))
and it works by giving me 2014-02 for 02/07/2014
I would like it to read 02/2014
Not sure how to change?
Thanks
Joe
February 7, 2014 at 9:47 am
You want to use CONVERT with a format code. (Reference)
Can you handle that? or you need more help?
Remember that this information is available with F1 on SSMS.
February 7, 2014 at 1:47 pm
A CONVERT to format 101 will give us format "mm/dd/yyyy". Then, using STUFF, we can remove the "dd/", leaving you with what you want:
SELECT STUFF(CONVERT(varchar(10), GETDATE(), 101), 4, 3, '')
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
February 7, 2014 at 2:53 pm
Or you could use code 103 with a RIGHT or SUBSTRING.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply