function for retrieving specific number of months