This topic is locked
[SOLVED]

 add dates to find sum

5/14/2010 6:56:53 PM
PHPRunner General questions
swant author

I am using phprunner 5.2 currently demo and going to buy enterprise. I want to for a report add two columns together and tehy are dates in my report. I have an older date and and end date. i want a column to show how may days they are apart. How would i accomplish this. Also in my main table would i have to add another column for this? I am a super newby to mysql and php.

A
ann 5/17/2010

Hi,
to add a column with date difference in report you don't have to create a column in main table. You can just create an alias for the difference in two dates. Go to the Edit SQL query tab of the report page and switch to the SQL mode and add a code. Here is a sample for MYSQL:

SELECT

Id,

StartDate,

EndDate,

DateDiff(EndDate, StartDate) AS NumberOfDays

FROM TableName



For other databases MYSQL function DateDiff() should be replaced by corresponding function.

Then proceed to the Choose fields tab and check the Show column for the NumberOfDays alias.

swant author 5/17/2010

Select

swant author 5/17/2010

Select

swant author 5/17/2010

SELECT

swant author 5/17/2010

This is what I needs it to look like But i also need the date difference between Date Build Request and Released to Prod everything that i find for mysql commands tends to not work and also the one that was submitted to me from you bombs out even if i make a new query from scratch. any suggestions
SELECT

List ID,

Name of Careset,

Build or Maintain,

Owner,

Date Build Requested,

Department Approval,

Compliance Approval,

Lab Approval,

Pharmacy Approval,

Quality Approval,

Radiology Approval,

Released to Prod

FROM List of Needs

WHERE (Build or Maintain ="Build")

A
ann 5/18/2010

Hi,
it's difficult to tell you what's happening without seeing actual files. Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.

S
swanside 5/18/2010

Try this.

SELECT

List ID,

Name of Careset,

Build or Maintain,

Owner,

Date Build Requested,

Department Approval,

Compliance Approval,

Lab Approval,

Pharmacy Approval,

Quality Approval,

Radiology Approval,

Released to Prod,

(SELECT (DATEDIFF(Released to Prod,Date Build Requested))) AS TimeTakeToProd,

FROM List of Needs

WHERE (Build or Maintain ="Build")

swant author 5/18/2010

Line 14 errors, the new select statement



Try this.

S
swanside 5/18/2010



Line 14 errors, the new select statement


Sorry remove the , from the last line of the sql

swant author 5/19/2010

There were single quotes instead of back ticks that were causing the issue of it not working
heres what works and should have looked like

SELECT

Name of Careset,

Build or Maintain,

Owner,

Date Build Requested,

Department Approval,

Compliance Approval,

Lab Approval,

Pharmacy Approval,

Quality Approval,

Radiology Approval,

Released to Prod,

DATEDIFF(Released to Prod, Date Build Requested) AS Days in Build Status

FROM List Of Needs

WHERE (Build or Maintain ="Build")



Sorry remove the , from the last line of the sql