The code below highlights a TRANSFORM/SQL 'curiosity'- at least in VFP 7. Is there any reason why the 2nd and 3rd SQL should be different? As far as I'm concerned, the 2nd (which returns only 5 supposed unique values) is wrong and exposes a bug. Is this issue addressed in VFP 8 or planned in 9?
Brian
CREATE TABLE test (testdate d, testdate2 c(6))
FOR x = 1 TO 100
APPEND BLANK
ENDFOR
REPLACE ALL testdate WITH {12/31/2003}-RECNO()*150
REPLACE ALL testdate2 WITH (TRANSFORM(YEAR(testdate))+PADL(TRANSFORM(MONTH(testdate)),2,"0"
)
SELECT dist (TRANSFORM(YEAR(testdate),'####')+PADL(TRANSFORM(MONTH(testdate),'##'),2,"0"
);
GROUP BY 1 FROM test nowait&& returns 5 unique values
?"using TRANSFORM with an explicit format on a yyyy/mm distict returns "+TRANSFORM(RECCOUNT())+" unique values"
SELECT dist (TRANSFORM(YEAR(testdate))+PADL(TRANSFORM(MONTH(testdate)),2,"0"
);
GROUP BY 1 FROM test nowait&& returns 5 unique values
?"using TRANSFORM without an explicit format on a yyyy/mm distict returns "+TRANSFORM(RECCOUNT())+" unique values"
SELECT dist testdate2 ;
GROUP BY 1 FROM test nowait&& returns 100 unique values
?"using TRANSFORM without an explicit format into a chr field first on a yyyy/mm distict returns "+TRANSFORM(RECCOUNT())+" unique values"
DROP TABLE test
Brian
CREATE TABLE test (testdate d, testdate2 c(6))
FOR x = 1 TO 100
APPEND BLANK
ENDFOR
REPLACE ALL testdate WITH {12/31/2003}-RECNO()*150
REPLACE ALL testdate2 WITH (TRANSFORM(YEAR(testdate))+PADL(TRANSFORM(MONTH(testdate)),2,"0"
SELECT dist (TRANSFORM(YEAR(testdate),'####')+PADL(TRANSFORM(MONTH(testdate),'##'),2,"0"
GROUP BY 1 FROM test nowait&& returns 5 unique values
?"using TRANSFORM with an explicit format on a yyyy/mm distict returns "+TRANSFORM(RECCOUNT())+" unique values"
SELECT dist (TRANSFORM(YEAR(testdate))+PADL(TRANSFORM(MONTH(testdate)),2,"0"
GROUP BY 1 FROM test nowait&& returns 5 unique values
?"using TRANSFORM without an explicit format on a yyyy/mm distict returns "+TRANSFORM(RECCOUNT())+" unique values"
SELECT dist testdate2 ;
GROUP BY 1 FROM test nowait&& returns 100 unique values
?"using TRANSFORM without an explicit format into a chr field first on a yyyy/mm distict returns "+TRANSFORM(RECCOUNT())+" unique values"
DROP TABLE test