Using Crystal Reports version 8. Trying to restrict data retrieved based on date range provided by the user.
Here is the formula I am trying to use in the Select Expert:
{Query.current0} <> 0.00 and
{Query.status} in ["PIF", "SIF"] and
{Query.closed} >= DateTime ({?Start}, Time (00,00,00)) and
{Query.closed} <= DateTime ({?End}, Time (23,59,59))
When I click the error checking button, CR gives the error "A date-time is required here" and puts the cursor at the end of the second line after the "and".
I have confirmed both {?Start} and {?End} are Date parameters and they do have data in them. {Query.closed} is a datetime in the original database, and if I remove the {Query.closed} date restrictions, the report runs fine (it just pulls all the data in the database!).
Oddly enough, I have another Crystal Report that runs just fine using this formula in the Select Expert:
{Collect2000Log.LogWhen} >= DateTime ({?FromDate}, Time (00,00,00)) and
{Collect2000Log.LogWhen} <= DateTime ({?ToDate}, Time (23,59,59))
In both reports, the parameters involved are Date parameters, and both {Collect2000Log.LogWhen} and {Query.closed} are datetime fields. One major difference is the PIF/SIF report (the one with the errors) is built on a saved Crystal SQL Query and the one without errors was not.
Can anyone help me spot what I am missing?
After further exploration, I'm not sure what the actual issue was, however I re-created the report WITHOUT the use of Crystal SQL Queries and it is now pulling data just fine. Would appreciate knowing the details if anyone can explain, but for now mystery is solved!
Related
I inherited supporting a database from an employee that left the company years ago. The team that uses this is being forced to upgrade from SQL Server 2008 to SQL Server 2017.
Everything seems to work fine but there is a form that has text boxes that show some counts of the data using a DCount function. The problem kicks in when it is trying to subtract today's date (using Date()) from a column [DateReceived] (of type smalldatetime in SQL Server) from the table in the DCount function.
This works
=DCount("[ClaimNum]","tblClaimsData","[ClaimStatus] = 'Open' and #2/4/2021# - [DateReceived] between 45 and 59")
This throws an error
=DCount("[ClaimNum]","tblClaimsData","[ClaimStatus] = 'Open' and Date() - [DateReceived] between 60 and 90")
I cannot seem to figure out a workaround for the Date() function IF that is where the problem is. I have a query that will count the data table but I cannot have a query as a control source for a text box, nor can I get a value of another text box in place of the Date() in my DCount function.
Any thoughts here? Thanks!
ODBC SQL subtraction error
Form with counts - the one that works has the date hard coded in the DCount function
The error message is crystal clear. Your data type is now DateTime2, which the ODBC driver reads as text, causing any numeric date handling to fail.
Best option is to change the data type to DateTime and your code will work.
Else, convert the text dates to true dates:
=DCount("[ClaimNum]","tblClaimsData","[ClaimStatus] = 'Open' and Date() - DateValue([DateReceived]) between 60 and 90")
That may still fail, however, if the text dates contain milliseconds, like 2021-02-04 15:42:30.000.
If so, these must be chopped off before converting.
In Report Builder 3.0, there's a report that I am rebuilding (this 'old' report is being fed from old DB, I am rebuilding report using data from new DB). The old report appears to somehow be using a WHERE clause equivalent, but I can't figure out how it's working. Here's the basic structure...At the bottom is the tablix that lists multiple rows ([DueDt1]) and the MIN function above is pulling the MIN date, but it is pulling the MIN date only for the rows where the [Total Still Due] is > 0.
(nothing more than a MIN, if anyone was curious)
So to see the actual results, this first shot here shows the supposed "MIN" date of 7/27/2019:
However, the real MIN date is actually 6/21/2019. It's clearly only fetching the MIN date as it pertains to some kind of WHERE clause equivalent (I say equivalent because I know there's no WHERE option in SQL Report Builder) that's filtering to only look at rows with the [Total Still Due] being > 0.
Here's the thing: this is what I want my new report to do, but when I attempt to use a MIN date function, it pulls the "real" MIN date. So how is this old report effectively using a WHERE equivalent? There is only one dataset that the old report is using, and only one dataset that my new report is using. Somehow, the old report has some kind of WHERE clause equivalent and I have no idea where or what it is. Any ideas as to how this is occurring?
I'm creating a dashboard of marketing leads from a Data Source that has two columns of dates in it. One of the columns is historic dates that were imported. One of the columns is all new leads, with accurate dates.
I'm trying to create a new field in Data Studio for use as the Date Range Dimensions. Essentially, if historic date is null, then use new date. If it isn't null, use the historic date.
This is my current code:
CASE
WHEN Historic Date IS NULL THEN Created Date
ELSE Created Date
END
There are no errors thrown when creating the field, but when I set it as the Date Range Dimension, I get this error:
This data source was improperly configured.
Invalid argument type.
Seems that Case function has as output a string which cannot be recognized or configured as a date in google Studio. It can be a bug from Data Studio, but the fact is that I have the same problem and I solve it converting the output of case into a date format.
I have no much time to explain/expose it better, therefore I will put the function that worked for me:
todate(CASE
WHEN Status IN ("X","NMX","MX") THEN Cancel Dt cf
ELSE Confirm Dt cf
END
,'%Y%m%d','%Y%m%d')
Hope it fixes you well you or at least gives you some light/direction on how to solve it.
I've been stuck on this issue for most of this morning...I am trying to work through a display issue with my SSRS report regarding my "As of Date". The data behind this report is loaded nightly, meaning the data is only as good as yesterdays actual date. My problem is that my report currently defaults the parameter to =#AsOfDate = Today().
However, in order for this to be accurately reflected, whenever a User wants to change the date on this report, I would need the "As Of Date" to always reflect yesterday. So if we ran this report for today 3/7/16, the Data behind the report is from 3/6/16 thus, the report should show "As of" 3/6/2016, and if they selected 2/29, on View Report, it should show As Of 2/28/16, etc.
My SQL statement in the report is using a column from my report table called CurrentDate which just holds the nightly load date. It states ...
WHERE #AsofDate = CurrentDate
Does anyone have any idea how I could accurately script this so that a User can always know that the data is from the night before?
Thank you!,
Try setting your AdOfDate to the default value for yesterday (calculated):
#AsOfDate = DateAdd(DateInterval.Day, -1, Today())
Otherwise, you could set your SQL query to do the same
WHERE AsOfDate = DateAdd(d, -1, GetDate())
I am working with SQL Server Report Builder 2008 R2.
I have a dataset that contains DateEntry (date, null) and TimeStampAuto (time(7), null) columns. I am trying to write an expression for concatenating those two values, so I can put it under DATETIME column on the report table. I tried the following but it does not work. It displays "#Error."
=First(Fields!DateEntry.Value, "Report1) & " " & First(Fields!TimeStampAuto.Value, "Report1)
When I just put the first part of the expression shown above, the report displays the date with some random time value (5/1/2015 12:00:00 AM). However, I did not put any time value in DateEntry. I only put the dates.
When I put the second part of the expression shown above, the report displays correct time that the data has.
I don't know why I can not concatenate those two.
The system type of the DateEntry.Value will be a DateTime value which is the readon that your report is showing 5/1/2015 12:00 AM even though it is only a date field in the database.
You need to format the date to only include the day,month and year to remove the included default time of 12:00 am
you will probably need to check for null values in both your date and time fields. you will also need to format the time filed to exclude any default date information.