Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 stuggling with datediff function

Author  Topic 

twodayrule
Starting Member

1 Post

Posted - 2007-11-02 : 04:45:24
recently i created a system using php and mysql to record faults that the ict technicians could get reported faults out of. so far it does everything i want but some senior members of staff now want the front end to give a report of status, one of the things they wish to see is how many jobs have been completed this week month and year

within my tables is a field date. naturally it has the date submited contained within it. the code i have been using to try and get an output is

mysql_query("SELECT date, datediff('day', date, CURRENTDATE) FROM softwarerepairtable WHERE datediff<= '7' and complete='yes' ");

the complete feild is another contained within the datebase. i have also tried SELECT * datediff('day', date, CURRENTDATE) FROM softwarerepairtable WHERE datediff<= '7' and complete='yes' ");

unfortunatly my limited knowledge of php and sql is holding me back on this. any help guys would be appriacted

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-11-02 : 04:56:46
This is SQL Server forum. You should post at www.mysql.com

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-11-02 : 04:58:35
Also in mysql, you cant use day as first parameter. It should be

SELECT date, datediff(date, CURRENT_DATE()) FROM softwarerepairtable WHERE datediff(date, CURRENT_DATE()) <= 7 and complete='yes'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -