Page 1 of 2

Passing dates as parameters

Posted: Wed May 18, 2011 3:29 am
by rahulmes
Hi.

I am trying to pass dates as parameters to my mySQL report. After going through the forums, I have taken these steps:

1. In the SQL query, we have to prefix an @ in the parameter. I have done this and this is my query:

Select * from visit_master, company_master where visit_master.CompanyID = company_master.CompanyID and DateOfVisit between @DateBegin and @DateEnd

2. In the DataSource dialog, I have defined 2 parameters DateBegin and DateEnd and defined their datatype as DateTime.

3. I have then declared 2 variables FromDate and ToDate. I have given their default values as 1/1/1970 0:00:00 AM.

4. I have assigned the expression values of the DateBegin and DateEnd parameters as FromDate and ToDate respectively.

5. I am passing the parameter values in the format of YYYYDDMM.

This is my hyperlink:
http://localhost/quickstart/stimulsoft/ ... d=20110601

When I run this query in my database, I get back 3 rows

Select * from visit_master, company_master where visit_master.CompanyID = company_master.CompanyID and DateOfVisit between 20110501 and 20110601

But, in the report no rows are getting returned. What could be the issue?

Thanks in advance for any help.

Passing dates as parameters

Posted: Wed May 18, 2011 8:12 am
by Jan
Hello,

It very hard to say where your problem is located. Please show code which you use to run report and also we need see your report. You can check "SQL.Parameters from Dialog Form" sample report in Demo.exe application from standard delivery.

Thank you.

Passing dates as parameters

Posted: Wed May 18, 2011 8:57 am
by rahulmes
Dear Jan

Thanks for the prompt reply. I am not using any code. The report is directly generated through the hyperlink.

I have attached the mrt file and a small sql file. Can you please instruct me on how to show the records between 2 visit dates? In other words, I want to see a list of visits made between 01-04-2011 and 01-05-2011.

Thanks.

Passing dates as parameters

Posted: Thu May 19, 2011 5:41 am
by Vladimir
Hello,

We have analyzed your reports and data. For Reports.Fx for PHP, there is another way to use parameters in SQL query. Please use the following query form:
Select * from visit_master, company_master where visit_master.CompanyID = company_master.CompanyID and DateOfVisit between {DateBegin} and {DateEnd}
In the GET request date can be specified in the following format (yyyy/MM/dd or yyyy-MM-dd):
Thank you.

Passing dates as parameters

Posted: Wed May 25, 2011 11:41 pm
by rahulmes
Thanks it worked, Vladimir.

However, I had to enclose the dates between single quotes like this if I used / or - as the separator:
Only this format worked well without quotes,

Passing dates as parameters

Posted: Thu May 26, 2011 8:37 am
by Vladimir
Hello,

You can also use the yyyy-MM-dd date format, it should correctly read in the last prerelease builds of Reports.Fx for PHP.

Thank you.

Re: Passing dates as parameters

Posted: Thu Feb 13, 2020 12:38 pm
by usman
I am facing with the same problem code is like below if anyone can help me
Select id,name,publishing_date from books where (id = {bid} or category_id = {gid} or publishing_date between '{DateBegin}' and '{DateEnd}')
it gives me this error
The error of compilation
The error of compilation is found in the 'Report' report:
The name 'DateBegin' does not exist in the current context

Re: Passing dates as parameters

Posted: Wed Feb 19, 2020 8:43 pm
by Lech Kulikowski
Hello,

Please send us a sample report with test data that reproduces the issue for analysis.

Thank you.

Re: Passing dates as parameters

Posted: Tue Jul 28, 2020 12:20 pm
by shravan.pitla
Is this issue resolved i am also facing the same problem with date parameters

Re: Passing dates as parameters

Posted: Wed Jul 29, 2020 2:56 pm
by Lech Kulikowski
Hello,

Please send us a test data fro your report.

Thank you.