Crystal Report formula with datediff not working as expected
We need a Crystal Report formula to display the number of seconds the oldest arriving call has been waiting. Across multiple resources that can each have an "oldest call". The database stores a datetime value for the time the oldest call arrived. If there are no waiting calls, then this field is NULL. (MSSQL database). It seemed reasonable to implement this in a formula that 1) discovers the minimum of "oldest call" timestamps in the selected records, and 2) to use "datediff" to produce the difference (in seconds) between the "oldest call" timestamp and current time.
The first attempt at this relied on "implied" iteration that could be done within a formula. Something like:
data: OLDESTARRIVALTIME
null
'2014-06-14 08:08:08.000'
null
'2014-06-14 08:07:55.000'
null
whilereadingrecords;
datetimevar minArrival;
if isNull({SVCCLASSMEASURES_VW.OLDESTARRIVALTIME}) = False
and minArrival < {SVCCLASSMEASURES_VW.OLDESTARRIVALTIME} then
minArrival := {SVCCLASSMEASURES_VW.OLDESTARRIVALTIME};
DateDiff("s", minArrival, {SVCCLASSMEASURES_VW.UTCDATE})
We tried storing the values of OLDESTARRIVALTIME in an array. We could see it iterating, but the values in the array only contained
the column value from the first record.
This was to solve the problem of screening null values and producing the minimum of the set.
Since that didn't work (and the web articles seemed to imply this would iterate over all the records, we tried another approach. This
time we set NULL timestamps in the table to a timestamp far in the future, so that we could directly apply "minimum" to produce
the correct "begin" for datediff.
data: OLDESTARRIVALTIME
'2030-01-01 00:00:00.000'
'2014-06-14 08:08:08.000'
'2030-01-01 00:00:00.000'
'2014-06-14 08:07:55.000'
'2030-01-01 00:00:00.000'
datetimevar minArrival = minimum({SVCCLASSMEASURES_VW.OLDESTARRIVALTIME});
datetimevar minUTC = minimum({SVCCLASSMEASURES_VW.UTCDATE});
if minArrival < minUTC then
DateDiff("s", minArrival, minUTC)
else
0
(minUTC would be current time in UTC)
So, to start things off, the last formula produces negative numbers! They hover in negative seconds within a negative minute (-33, -45, etc.).
That's inconceivable, considering the test for minArrival < minUTC. Both of the fields are "datetime".
As it turns out, in the near term, it's most important to get the second formula working. And, of course, insights into getting the first
formula to work are welcome as well!
Have we run into some weird behavior of the "DateDiff" function?
Thanks!
If DateDiff is always returning a negative number you could try swapping the dates around in the call to DateDiff - it should look like this:
DateDiff("s", minUTC, minArrival)
Or you could use the Absolute Value of the calculation:
Abs(DateDiff("s", minUTC, minArrival) )
As for your first formula, you need to initialize the variable to a value prior to using it in the comparison. If you don't, its value is null and comparing it against a value won't work. (See What is Null and Why is it Important for Crystal Reports | SAP BI BLOG for a blog that I wrote about working with nulls in Crystal.)
You should change your existing formula to something like this:
whilereadingrecords;
datetimevar minArrival;
if OnFirstRecord then minArrival := DateTime(2013, 1, 1, 0, 0, 0);
if not isNull({SVCCLASSMEASURES_VW.OLDESTARRIVALTIME})
and minArrival > {SVCCLASSMEASURES_VW.OLDESTARRIVALTIME} then
minArrival := {SVCCLASSMEASURES_VW.OLDESTARRIVALTIME};
Note how I changed the If statement. Also, you want to replace minArrival with the field value if the field is less than the current value of minArrival - so you need to use ">" instead of "<" in the comparison. Place this formula in the details section. It will now show anything because of the semi-colon on the end. This will ensure that it gets evaluated for every record.
Now, create a second formula that looks like this:
whileReadingRecords;
datetimevar minArrival;
DateDiff("s", minArrival, {SVCCLASSMEASURES_VW.UTCDATE})
Place this formula in a footer section - it will not work in a header section. If you need it in a header section you might be able to take the "whilereadingrecords" off of both formulas and use the "Maximum()" summary function to get the correct value.
-Dell
Similar Messages
-
Crystal Report viewer print dialog not working.
I have an asp.net website that i developed in VS 2010 that is using Crystal Reports 10.2. Everything works fine in the devleopment environment but when I upload it to the production server the print dialog wont print.
The print dialog opens up just fine but when i click print it says "Class not registered" at the top of the dialog.
How can I fix this problem?
Thanks in advance.Hello,
Please search before posting.
Visual Studio 2010 is not meant to work with Crystal Reports 10.2.
Download CR4VS2010 here:
[/people/blair.wheadon/blog/2010/07/29/crystal-reports-for-visual-studio-2010-beta-2-and-runtimes-now-available|/people/blair.wheadon/blog/2010/07/29/crystal-reports-for-visual-studio-2010-beta-2-and-runtimes-now-available]
Thanks,
Bhushan. -
Exporting Crystal Report to HTML is not working in Windows 7
Hi Sir,
I am trying to export Crystal Report to HTML format using VB.NET code. Functionality is working fine at Windows XP Environment (Save to Disk, Open an Application and Email Attachment). But the same functionality is not working at Windows 7 Environment (both 32-Bit as well as 64-Bit).
Below is the code to Exporting Crystal Report to HTML in VB.NET.
Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions
Dim CrFormatTypeOptions As New HTMLFormatOptions
Dim vFormat As Integer
Dim CrExportOptions As New ExportOptions
Dim vRdReport As New ReportDocument
Dim sfd As SaveFileDialog
Dim vFileName As String = Nothing
vRdReport = vRptSource
sfd = New SaveFileDialog
If Not (vRptPath = "") Then
sfd.InitialDirectory = vRptPath
End If
sfd.Filter = "Webpage, Complete(.htm;.htm)|.htm|Web Archive, Single file(.mht)|.mht|Webpage, HTML only(.htm;.html)|.html"
If sfd.ShowDialog = DialogResult.OK Then
' Set the disk file options.
CrDiskFileDestinationOptions.DiskFileName = sfd.FileName.ToString()
Else
Return
End If
CrExportOptions = vRdReport.ExportOptions
CrFormatTypeOptions.HTMLFileName = vFileName
CrFormatTypeOptions.HTMLEnableSeparatedPages = True
CrFormatTypeOptions.HTMLEnableSeparatedPages = True
CrFormatTypeOptions.HTMLHasPageNavigator = True
CrFormatTypeOptions.UsePageRange = True
With CrExportOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.HTML32
.DestinationOptions = CrDiskFileDestinationOptions.DiskFileName
.FormatOptions = CrFormatTypeOptions
End With
vRdReport.Export()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Code working fine at Windows XP, But it is not woking in Windows 7 environment.
Please can anyone share your valuable thoughts or ideas reg. this.
Thanks in Advance
Deivanayaga Perumal D.user13509659 wrote:
Run this code to reproduce the issue.Which issue?
It looks like inheritance is broken in the component hierarchy for JFrame in Windows 7 JDK 1.6.0_23-b05. The only thing remotely related to inheritance in your code snippet is the WindowListener, which does little. See camickr's advice about built-in exit management.
EDIT - using the post title as a clue, I realize you may be talking about the component hierarchy, and whether the contentPane's background is visible through the upper layers. Instead of guessing, I'd prefer you describe your "issue" accurately (observed vs expected behavior).
Edited by: jduprez on Feb 10, 2011 1:01 PM -
Crystal Report Viewer Print does not work for IE7
Post Author: ssdudeveloper
CA Forum: .NET
When I view a report in IE7, and click the Print button in the Crystal Reports Viewer toolbar, an empty dialog window opens and no print dialog appears. The print functionality works correctly when viewing the same report using an IE6 browser.
I have tried changing the browser security settings (as per http://technicalsupport.businessobjects.com/cs/forums/thread/3171.aspx) - with Automatic prompting for file downloads set to Enable, but this does not resolve my problem.
Is this a known compatability issue with IE7? Are there any workarounds/solutions to this?Hello,
Please search before posting.
Visual Studio 2010 is not meant to work with Crystal Reports 10.2.
Download CR4VS2010 here:
[/people/blair.wheadon/blog/2010/07/29/crystal-reports-for-visual-studio-2010-beta-2-and-runtimes-now-available|/people/blair.wheadon/blog/2010/07/29/crystal-reports-for-visual-studio-2010-beta-2-and-runtimes-now-available]
Thanks,
Bhushan. -
MySQL 5.5, Crystal Report for Visual Studio not working when hosted IIS
Software and Component detail
Microsoft visual studio 2010
MS .NET Framework
Version 4.0.30319 RTMRel
MYSQL SERVER Database
Version 5.5
MySQL Connector 6.6.4 64 Bit
MySQL ODBC Driver Version 5.2.a
Crystal Report for Visusl Studio 64 Bit 13.0.5
(CRforVS_redist_install_64bit_13_0_5)
Current Setup
1. I have WebSite in ASP.NET Visual Basic which works fine and is connected to MySQL Database, using MySQl Connector 6.6.4 64 bit
and is using a connection string,defined in web.confg.
2. I am using a Crystal report( It is very complex report, so cannot dare to redo it). Data Source for the report is set using a connection string
DRIVER={MySQL ODBC 5.2a Driver};SERVER=Licensedb;DATABASE=License;pwd=root;PORT=3306;OPTION=3 and this report is called from website using the below code
Dim crystalReport As ReportDocument = New ReportDocument()
Dim repPath As String = Server.MapPath("~/Reports/") + "LicenseReport.rpt"
crystalReport.Load(repPath)
CrystalReportViewer1.ReportSource = crystalReport
crystalReport.SetParameterValue("InstanceID", CInt(Session("sessionInstanceID")))
crystalReport.Refresh()
crystalReport.SetParameterValue("InstanceID", CInt(Session("sessionInstanceID")))
CrystalReportViewer1.Visible = True
3. The above setup works fine, when I run the website from Visual studio 2010. But when i use IIS 7, the aspx page having crystal report viewer control load and its blank.
However it work very well from studio it self.
4. So I changed the setup in point 2, by having a ODBC Data source defined. And changed the report accordingly. It work fine in Visual studio , but from IIS
it gives error "Failed to Open Connection, Failed to Open Connection <Crystal Report File name.rpt>"
5. I tried creating a System DSN and same connection string in IIS Application Connection string. But nothing changed.
Please can anyone point in correct direction. I must admit this is my first website development work, so I might have overlooked some minor details.
Any help would be much appreciated.
Thanks
Dilpreet ([email protected])hello again. I fear that what is said in that article does not apply to my particular case.
First of all i am using the Crystal Report Basic 2008, which I think is not the same product as Crystal Reports 2008.
In addition, printing fails always, on my PC and on the web server.
On the other hand I can not find anywhere printcontrol.cab file or printcontrol.dll, just do not exist either in my PC or on the web server.
The folder where the report viewer is located is not CrystalReportViewers12, is CrystalReportWebFormViewer4, and is located at wwwroot\aspnet_client\system_web\2_0_50727\
Investigating I found something, but has not helped me:
[http://social.msdn.microsoft.com/forums/en-US/vscrystalreports/thread/0af08d25-dd71-41ce-92fa-ca374f933eaa/]
This problem is what always happens to me when on my local PC I access my web server by its public IP.
I think I must resign myself to use only the PDF print
thanks anyway -
Printing from ActiveX Control in crystal report 10 in IE7 not working
Hi,
I am using ActiveX Control for printing in Crystal Report version 10 using Java. When I click on print button, ActiveX control dialog box opens and then click print button, the dialog box shows it's printing and does not stop and there is no print on printer. If any body have idea to resolve this issue, kindly tell me as soon as possible.
Thanks in Advance,
Nasir NawabHello,
CR 10 is not supported in IE7. It may work if you use the Legacy mode in IE7. Also check your pop-up blocker and allow ActiveX controls to be installed.
Thank you
Don -
Crystal Reports dynamic parameter does not work in InfoView
Hello,
We have developed Crystal Reports in CR2008 on top of SAP infoset and we have one of our selection parameter as dynamic parameter. It works fine in the CR Dev tool but when i upload the report in the InfoView, report does not show any value in the "Available Values"
Any input will be much appreciated.
Thanks.I did found the solution for this, i had to go into Business View Manger (BO Client Tools) and Schedule the LOV (List of Values). This is odd setting! but it works....
-
Interface Crystal Report Server with Lotus Notes
Hi,
Does "Crystal Server 2011" or "Crystal Report Server 2008" provides an interface with Lotus Server so that user can schedue and deliver report to end user through Lotus Domino? (ie: user can receive reports in an email through Lotus Notes)
Thanks!
Albert LUOMoved to BOE/CRS Admin forum
-
Crystal Report XI - .csv export not working
Hi Folks,
I developed reports in Crystal Report XI R2 version (with service pack 6) and calling them from Power Builder 11.5. When I export the report to .csv format I see only parameter names with values (supplied to call this report) in csv file.
For eg:
Parameters are
Start Date: 01/01/2012
End Date: 02/01/2012
CompanyID: 21234
Regular output:
colum1 colum2 ...... columnn
data1 data2 datan
data1 data2 datan
data1 data2 datan
..... 10 records
csv output looks like this:
Start Date 01/01/2012 End Date 02/02/2012 CompanyID 21234
Start Date 01/01/2012 End Date 02/02/2012 CompanyID 21234
Start Date 01/01/2012 End Date 02/02/2012 CompanyID 21234
..... 10 records
Please let me know what changes should I do.
Thanks
IndraHi Indra,
Subreports are not exported to CSV, unfortunately. The multiple rows that you see are actually the detail sections that are repeating.
Try exporting to Excel and then to .csv from Excel.
-Abhilash -
Crystal Reports 8.5 does not work on Vista & Windows7
Hi,
We have a program written in VB6 and we are using Crystal Reports 8.5. The reports are fine on Windows XP but are not running on Vista and Windows 7. I found many people over the internet have this issue but none of them have gotten any resolution.
Any solution?
Thanks,
NadeemHi Nadeem,
Please check this:
Versions of Crystal Reports are supported on Windows Vista:
[https://www.sdn.sap.com/irj/scn/wiki?path=/pages/viewpage.action&pageid=64259646]
Regards,
Shweta -
Integrate Crystal Reports 2008 in Lotus Notes 8.x
We allready use Crystal Reports 2008 with Lotus Notes 8.x trough NotesSQL 8.5. This works fine.
Now we want integrate Crystal Reports 2008 directly in Lotus Notes 8.x. so that the user can start reports directly from his Lotus Notes Application. Of course, data has to be retrieved in realtime (not with data stored in the report) and he should be able to pass parameters from a lotus notes form.
All informations we found are quit old (Crystal Reports 8.5 and Lotus Notes R5). Does anyone has an idea how to start and where to find new documentations? Is there maybe even a sample application availabl?
Any help is welcome!Hello Alain, I have the same troubles. I have some databases with Crystal Reports 9. But no solution for Crystal Report 2008.
Which dll's are needed? -
Crystal Report in InfoView is not displaying the parameter
Cheers All,
We have a Crystal Report which is connected to the BEx query. We also have parameters based on variables in BEx.
When we run the report directly from Crystal, everything is fine.
However, when we run the report from InfoView, when I click on the "..." button beside the parameter to make the selection, everything hangs up.
This (static) parameter is based on a variable which is based on a compounded characteristic 0ASSET_AFAB.
The compunding keys are :1) Company code 2) Asset 3) Sub-asset.
The user is providing the Company code in another parameter, but the user is not providing the Asset, nor the asset sub-number... so all the iterations of asset/sub-asset/depreciation area are displayed - and this works at BEx level, and it works when the report is run directly from the Crystal Reports, however this does not work when the report is run from the InfoView.
What would be the best course of action?
Regards,
DmitriyHi Rajiv,
In OIM 9.1 we are using the stored procedure to get the values for all the fields.In the stored procedure we are using the cursor to store the list of values but in the BI Publisher we are using the SQL queries to retrieve the values for the fields in the report. In sql queries we are unable to handle the list of values for the fileds like User Groups and Resources provisioned/deprovisioned.
Please let me know the process even if we can get list of values for the fields using the SQL queries. -
Namespaces not working as expected
Hi, I've got problems with namespaces not working as expected. When I isolate a process into a new network and mount namespace, a newly mounted file system will be visible to all processes.
Steps to reproduce:
$ sudo unshare -mn bash
bash# mount -t sysfs sysfs /sys
bash# exit
$ cat /proc/mounts
Result:
/proc/mounts will contain a new line for sysfs. This means the /sys/fs/cgroups directory will appear to be empty as the new sysfs is mounted over the old However you can undo it by
sudo umount /sys
Expected result:
The /sys directory will only be new inside the bash process started using unshare and not anymore once you exit bash.
Did I understand something wrong? Or might this be a bug in the kernel?
Note that when using
unshare -m bash
without isolating the network namespace it will refuse to mount sysfs as it is already mounted or busy. Strange.Hello, because sysfs is shared, see unshare(1) for more details.
-
Formula Columns are not working in Reports 10g
Hi,
We converted the reports developed in Reports 6i to Reports 10g. When we run the report in Reports 10g Builder everything works fine. But when we deploy the same report in Oracle Application Server and invoking the report the formula columns are not working ie., the fields/ placeholder columns which are based on the formula column are not displaying any values in the report.
Please, someone help us in this regard.
Thanks & Rgds,
M TWhat version of Reports do you use..???
Greetings... -
Crystal Reports 2008 - dynamic parameters not returing all data
I am having the same issue with Crystal Reports 2008. Only returning 135 customers in a dynamic paramaters when the list should be 3288.
When I re-create the parameter by using a command instead of relying on Crystal to return the data from the db table Crystal returns only 5"pages" of customers to select from.
I have tried to run the report with this reduced selection & it then crashes.
Any ideas??This article may help you to increase the number of values in the parameter
KBase Article ID:c2017238
Article refers to: Crystal Reports XI BusinessObjects Enterprise XI
Symptom
For performance reasons, in Crystal Reports XI Release 1 and Release 2 the maximum number of values that are returned for a list of values is set to 1000. If you have a cascading List of Values (for example Country > Region > City), the lowest level (in this case City) will only display a maximum of 1000 values. This means that the higher-level prompts may display far fewer values than you expect. The list of values provides the data for the dynamic parameter list.
How can you modify the maximum number of values available in a dynamic parameter list?
Resolution
To increase the maximum number of values available in a dynamic parameter list, you must add a registry key.
CAUTION The following resolution involves editing the registry. Using the Registry Editor incorrectly can cause serious problems that may require you to reinstall the Microsoft Windows operating system. Use the Registry Editor at your own risk. For information on how to edit the registry key, view the 'Changing Keys and Values' online Help topic in the Registry Editor (Regedit.exe).
It is strongly recommended that you make a backup copy of the registry files (System.dat and User.dat on Win9x computers) before you edit the registry.
Crystal Reports XI Release 1
1. Create a registry key HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 11.0\Crystal Reports\DatabaseOptions\LOV.
NOTE Alternatively, you can create the registry key HKEY_CURRENT_USER\SOFTWARE\Business Objects\Suite 11.0\Crystal Reports\DatabaseOptions\LOV and that key will override the settings of the HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 11.0\Crystal Reports\DatabaseOptions\LOV key.
2. Add a string value "MaxRowsetRecords" and set the value to the maximum number of values that you desire for your report. For example, a value of 2000 will return up to 2000 values in the lowest level of a cascading parameter. NOTE: The value 0 (Unlimited) will not work with BusinessObjects Enterprise XI or Crystal Reports Server XI, you must specify another value.
NOTE The higher the number of values is, the longer it will take the Enter Values dialog box to populate with values.
3. After making changes to the registry, restart the affected service or application as required.
Crystal Reports XI Release 2
1. Create a registry key HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 11.5\Crystal Reports\DatabaseOptions\LOV.
NOTE Alternatively, you can create the registry key HKEY_CURRENT_USER\SOFTWARE\Business Objects\Suite 11.5\Crystal Reports\DatabaseOptions\LOV and that key will override the settings of the HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 11.5\Crystal Reports\DatabaseOptions\LOV key.
2. Add a string value "MaxRowsetRecords" and set the value to the maximum number of values that you desire for your report. For example, a value of 2000 will return up to 2000 values in the lowest level of a cascading parameter.
NOTE The value 0 (Unlimited) will not work with BusinessObjects Enterprise XI or Crystal Reports Server XI, you must specify another value.
3. After making changes to the registry, restart the affected service or application as required.
Regards,
Raghavendra
Maybe you are looking for
-
Printer does not show in Rendezvous in Preinter Setup Utility
I am using a G4 Ti 15" laptop usually connected wirelessly to an AirPort Extreme BS. Also connected to that BS is a desktop (ethernet), cable modem, and a HP LaserJet 2200 printer. If I connected the printer directly to the laptop, it prints. However
-
How to add row in multiple view object based on common entity object.
Hi , I have Jdeveloper version - 10.1.3.3.0 Oracle Database - 11g R2 I have a situation where i have to show data from one table in three adf tables on jsf page depending on a flag value in a column in table. For this purpose i have done the followin
-
Unable to change any file or document name in Finder
Can someone help me with following problem. Using Finder I am not able to change any folder or document name. Thus creating a "new folder" I even can not change that name! Thank you, Dorothee
-
Java Code file 1 meg... Can't open it
Hi All, I've just started using SJSE and have run into a couple of issues. First problem is that I can't open my java source file. Second issue is I can't get the ide to run my applet. It just displays a small box and that's it. Everything worked gre
-
How many managed Servers do you need?
Hi, One thing that has come up time and time again, is when trying to think about a new project and a new WL domain, is trying to know how many WL Managed Servers do you need? Does BEA have some sort of metrics which says ok for this amount of input