How do I prompt for a date range in report?

How do I prompt for a date range in report?

Postby JohnKlassen » Thu Jan 17, 2013 2:34 pm

Hi,

I have just created a report that displays all of the rows where vio_date_entered is within a date range.

Code: Select all
$sql = "CREATE TABLE #dataTable# SELECT * FROM violations ";
$sql .= "WHERE vio_date_entered > '2012-10-01' AND vio_date_entered < '2012-11-01' ";
$sql .= "ORDER BY vio_date_entered ";
nuRunQuery($sql);


How do I prompt the user for the beginning and ending date in the date range, ideally using a calendar? Is there a sample I could look at?

Thanks,

John
JohnKlassen
 
Posts: 148
Joined: Wed Dec 05, 2012 1:26 pm

Re: How do I prompt for a date range in report?

Postby johan » Sat Jan 19, 2013 7:42 pm

John,


You first have to create a new form (fill in name = date select - title = select -table = date - primary key = date and used for report = yes)
Add 2 textfields vfrom and vto (format 13-01-2007).You can leave all the other fields of form blank
Create new report with selection creteria form = date select
In report your code will be something like
Code: Select all
   
$from         =  reformatField('#vfrom#',11,$quotes = false);
$to         =   reformatField('#vto#', 11,$quotes = false);

$sql = "CREATE TABLE #dataTable# SELECT * FROM violations ";
    $sql .= "WHERE vio_date_entered > '$from' AND vio_date_entered < '$to' ";
    $sql .= "ORDER BY vio_date_entered ";
    nuRunQuery($sql);

look in wiki for other formats.

Hope this helps.
Johan
johan
 
Posts: 278
Joined: Sun Feb 27, 2011 7:46 pm
Location: Belgium

Re: How do I prompt for a date range in report?

Postby JohnKlassen » Sun Jan 20, 2013 2:06 am

Johan,

Thanks very much. I will try that.

John
JohnKlassen
 
Posts: 148
Joined: Wed Dec 05, 2012 1:26 pm

Re: How do I prompt for a date range in report?

Postby admin » Thu Jan 31, 2013 4:18 pm

.
admin
Site Admin
 
Posts: 3154
Joined: Mon Jun 15, 2009 9:53 am


Return to Report Writer



cron