Hi James,
Thank you for responding so quickly.
I am getting closer, but I am unsure what I need to update. It is now showing what the last day of the current and last month are, but it is not showing the age as in years at the end of each month. It is showing the Participant's date of birth. Goal is for it to show all the Participants that are going to be 65 for greater at the end of the month and the age should be in years.
here is my current code and output.
SELECT
a.GroupID AS 'Group ID'
, a.DepNo
, a.PartID AS 'Participant ID'
, a.CovCat AS 'Coverage Category'
, CONVERT(varchar(10), ToDate, 101) as 'Coverage End'
, CAST(CONVERT(varchar(8),DATEADD(mm,DATEDIFF(mm,0,GETDATE())+1,-1), 112) AS INT)
, CAST(CONVERT(varchar(8), b.ParticipantDOB, 112) AS INT) AS 'Age At End Of Current Month'
, CAST(CONVERT(varchar(8),DATEADD(mm,DATEDIFF(mm,0,GETDATE()),-1), 112) AS INT)
, CAST(CONVERT(varchar(8), b.ParticipantDOB, 112) AS INT) AS 'Age At End Of Previous Month'
FROM tblMemEnroll AS a
left join vwMember AS b on a.PartID = b.ParticipantID and a.GroupID = b.GroupID and a.DepNo = b.DepNo
WHERE a.CovCat = 'GME'
and b.ParticipantDOB <= '19521231'
AND a.ToDate >= getdate()
AND a.DepNo = '00'
order by a.GroupID
output:
(No column name) Age At End Of Current Month (No column name) Age At End Of Previous Month
20171231 19461108 20171130 19461108
20171231 19420329 20171130 19420329
20171231 19460518 20171130 19460518
20171231 19510808 20171130 19510808
20171231 19500924 20171130 19500924
Thank you.