Monday, July 31, 2017

SQL Reports from GP - a date problem

Just tried to update one of my SQL Reports by adding a date column from GP.  The column rendered fine in the SQL source, showing the date as expected.  However no matter what I did in SSRS I could only get #ERROR for the new column.

After banging my head some, and some more googling, I realized that perhaps the way GP stores the "no date" value, 1/1/1900, could be the problem.

So I changed my source to convert 1/1/1900 to nulls and like magic the dates started to show.

CASE WHEN datecol = '1/1/1900' THEN NULL ELSE datecol END

I believe 1/1/1900 is the start for SSRS dates.  So it might make sense.

Anyway the moral is if you are using GP date columns that have 1/1/1900 for a SQL Report you might want to do the conversion of 1/1/1900 to null.

** Update 12/18/17 **
Found another possible cause - using the "c" format code on a date field.  Made this typo mistake and was miffed why my dates showed #error - until I check and saw the "c" there.  Once I switched it to "d" the dates showed just fine!

No comments:

Post a Comment