We’re using SQL Server 2005 and wanted to append two integers into another one. Right now we’re summing the month and year of a date field, which isn’t really what we want. Instead, we’d like to append them together, but retain an integer.
Here’s what we have right now:
SELECT
YEAR( MeetingDate) + MONTH( MeetingDate) AS DateGroup
We’d like DateGroup to read 20118, 20119, 201110, 201111 etc. Trying to learn some good ways of doing this.
Consider using a leading zero for one digit months, i.e. 201108 rather than 20118, then it’s easy:
Otherwise you have to treat some months differently: