This topic is locked
[SOLVED]

 Annual Report for current year

11/7/2014 12:27:55 PM
PHPRunner General questions
N
nti author

I have an annual report which works, however, report requires user input for search criterion "between dates"...
In need of php for simple search for current year, example: between 01/01/YYYY and today().
I do not wish to utilize "hard coded date for specific year" which would require updating script every year.
Many thanks,

S
swanside 11/8/2014

You could make a custom view and put this in the SQL
SELECT * FROM TABLE WHERE Order_Date BETWEEN CURDATE() - INTERVAL 365 DAY AND CURDATE()
That will then return everything from the date the script is ran back 365 days

N
nti author 11/8/2014



SELECT * FROM TABLE WHERE Order_Date BETWEEN CURDATE() - INTERVAL 365 DAY AND CURDATE()


Thank you, swanside. Your example above gave me the support required to get it working.
Your example digging back 365 days.
I adjusted your "Where" example as noted below.
WHERE InvoiceDate BETWEEN CURDATE() - INTERVAL (DAYOFYEAR(NOW())-1) DAY AND CURDATE()
("InvoiceDate" my specific field name.)