SQLTeam.com | Weblogs | Forums

Years and Months


I have a column that shows the number of months of occupancy for a tenant. I would like to run a query that would take this figure and return the number of years and months of occupancy e.g. 6 months would return 0 years and 6 months and 38 months would return 3 years and 2 months. Any help would be appreciated.


Assuming your months column is of data type INTEGER, you can do the following:

	monthColumn/12 AS Years,
	monthColumn%12 AS Months


Thank you. That worked perfectly.