zachvaldez
asked on
Need help to filter EndDates in my SSRS Report
In my SSRS report, Im trying to add filter of
Enddates between 07/01/2015 to 06/20/2016 and nothing is coming back although the data says otherwise.
What formatting needed to be able to produce the desired results
Enddates between 07/01/2015 to 06/20/2016 and nothing is coming back although the data says otherwise.
What formatting needed to be able to produce the desired results
referring to How-come-no-expert-is-look ing-at-my- question
The error I'm getting is cannot compare data of type System.string and System.DateTime.
That piece of information is vital.
a. we now know you have an error, and
b. we know you are comparing a string to datetime
Do you have a column in one of the tables that LOOKS like dates but is text? (char/varchar etc)
That could explain the error.
or
You have a datetime column but the "dates" that you are comparing to are strings (text) that isn't being converted into dates
The error I'm getting is cannot compare data of type System.string and System.DateTime.
That piece of information is vital.
a. we now know you have an error, and
b. we know you are comparing a string to datetime
Do you have a column in one of the tables that LOOKS like dates but is text? (char/varchar etc)
That could explain the error.
or
You have a datetime column but the "dates" that you are comparing to are strings (text) that isn't being converted into dates
ASKER
What is the best way of doing a filter?
There is this dataset filter and a filter on the tablix object?
Either has different way of doing things. or should I do the filterin in the stored procedure?
There is this dataset filter and a filter on the tablix object?
Either has different way of doing things. or should I do the filterin in the stored procedure?
ASKER
Here's I convert my dates in the stored procedure because some are displaying 1900-01-01.
SELECT BID,SAM#,Survey,
CASE WHEN [BEGINDATE]='1900-01-01' then '' ELSE CONVERT(VARCHAR(10),BEGIND ATE,101) END AS BEGINDATE,
CASE WHEN [ENDDATE]='1900-01-01' then '' ELSE CONVERT(VARCHAR(10),ENDDAT E,101) END AS ENDDATE,....
but also in the SSRS report, I format the column to 1/1/0000 format...
any help is appreciated
SELECT BID,SAM#,Survey,
CASE WHEN [BEGINDATE]='1900-01-01' then '' ELSE CONVERT(VARCHAR(10),BEGIND
CASE WHEN [ENDDATE]='1900-01-01' then '' ELSE CONVERT(VARCHAR(10),ENDDAT
but also in the SSRS report, I format the column to 1/1/0000 format...
any help is appreciated
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The Data type for BEGINDATE AND ENDDATE is "Date" and by default sql server inserts the 1900-01-01 on those rows with no dates.
Have you tried my suggestion?
Don't convert those columns into varchar, but you can still get rid of the 1900-01-01 default date through the case expression using NULL instead of a blank string.
Don't convert those columns into varchar, but you can still get rid of the 1900-01-01 default date through the case expression using NULL instead of a blank string.
ASKER
Is there any difference between 1900-01-01 and 19000101 in the dates?
the STRING '19000101' is the SAFEST way to express a date for an implied conversion to date
the STRING '1900-01-01' is also a STRONG choice (for an implied conversion to date)
but not as safe as the previous format without dashes
in use:
[BEGINDATE]='19000101'
or
[BEGINDATE]='1900-01-01'
both strings are EXACTLY the same date/time
the STRING '1900-01-01' is also a STRONG choice (for an implied conversion to date)
but not as safe as the previous format without dashes
in use:
[BEGINDATE]='19000101'
or
[BEGINDATE]='1900-01-01'
both strings are EXACTLY the same date/time
ASKER
I will break that bad habit and I'll remember this conversation. Thanks for the tip.
If you are literally using "between" it maybe you have the values in the wrong order, the earlier of the 2 dates must be first.
[datecolumn] between '20150701' and '20160620'
Be careful if using between for date ranges; a much better way is to do this:
[datecolumn] >= '20150701' and [datecolumn] < '20160621' -- nb add 1 to latter date
see Beware of Between
Alternatively you are converting dates into strings but assuming they will still behave like dates (which is not true).
Regrettably I can't offer more explanations as there is very little information to work with.