I have a custom poller that polls an OID (APCupsBasicBatteryLastReplaceDate) that contains a date value in mm/dd/yy format. What is really strange and has me stumped is that I'm not having any success in converting the date value to any other date style. To demonstrate this issue, I've created the SQL below. I'm trying to convert the date format to yymmdd so I can later compare (CONVERT omitted from WHERE clause) for older than 3 years (Date_minus_3years). Also, notice the Report Writer result doesn't respect the 'AS ReplacementDate' clause and the column heading remains the table column name CustomPollerStatus.Status, not 'ReplacementDate'. The CONVERT and DATEADD using current getdate() works fine and generates the right date result (today's date 131012 minus 3 years). But, I'm stumped why the CONVERT function (highlighted in bold) is being ignored and returns the original table column name (Status) and date format (mm/dd/yy). From what I see, the CustomPollerStatus.Status column is defined in the table as nvarchar(1000).
Can anyone explain why the CONVERT function is not working? What am I missing?
SELECT CustomPollers.UniqueName AS PollerName
, convert(varchar(10),CustomPollerStatus.Status, 12) AS ReplacementDate
, convert(varchar(10),DATEADD(year,-3,getdate()), 12) as Date_minus_3years
FROM CustomPollerStatus
JOIN CustomPollerAssignment ON CustomPollerAssignment.CustomPollerAssignmentID = CustomPollerStatus.CustomPollerAssignmentID
JOIN CustomPollers ON CustomPollerAssignment.CustomPollerID = CustomPollers.CustomPollerID
WHERE (CustomPollers.UniqueName = 'APCupsBasicBatteryLastReplaceDate')
Report Writer Result