i’ve created a view and need to convert a datetime to following format:
2011 06 (year, empty-space, two digit numeric month)
What’s the best way to format it?
Here is the datetime(in a subquery in the view, “rounded” to month):
DATEADD(month, DATEDIFF(month, 0,Claim_Submitted_Date), 0) AS Year_Month_Submit
This gives me year,month and day(of course 01 because datetime was rounded to first day of month):
CONVERT(varchar,Year_Month_Submit,112)as Year_Month_Submit
Thank you in advance
Answer to Tim Schmelter :
You can compare the methods like this:
On my server, my version takes 1 second and the other version takes 3 seconds