I am running a query from pgAdmin3 against my postgresql database. I am wondering why it is returning values but all expected values. The query is:
SELECT P.SURNAME,
TO_CHAR(TO_DATE(SFE.GRANTDATE,'YYYY-MM-DD'),'DD Mon YY') AS GRANTDATE,
TO_CHAR(TO_DATE(SFE.REVOKEDATE,'YYYY-MM-DD'),'DD Mon YY') AS REVOKEDATE,
SFE.feedname
FROM SYS_FEED SFE,
PRINCIPLE P
WHERE SFE.USERID = P.ID
AND to_date(GRANTDATE,'YYYY-MM-DD') <= to_date('Nov-2006','Mon-YYYY')
The GRANTDATE column is type date and contains values in the format 2006-09-04. I want to return all rows where the GRANTDATE is less than or equal to the month-year provided. The problem i have is that it returns all the "less than" matching rows but does not return the "equals to" rows. So Jan-2006 to Oct-2006 is there but not Nov-2006.
Any advice would be great.
The GRANTDATE column is type date and contains values in the format 2006-09-04.If the column is of typedate, it doesn't "have" a format. If it "has" a format, it's not adate.