| | |
troubble with datediff function from database
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Nov 2007
Posts: 2
Reputation:
Solved Threads: 0
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
the complete feild is another contained within the datebase. i have also tried
unfortunatly my limited knowledge of php and sql is holding me back on this. any help guys would be appriacted
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 Syntax (Toggle Plain Text)
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
MySQL Syntax (Toggle Plain Text)
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
this is my own solution: try it. works for me
select * from mytable where
mydate BETWEEN date_format(Now() - INTERVAL 1 DAY,'%e/%c/%Y - %H:%i:%s') AND date_format(Now(),'%e/%c/%Y - %H:%i:%s') ";
this one sorts for 1 day.
if you need week, month, 45, 52 or 665 days
change this
Interval 1 to Interval 45
number is important....
to add dates change minus sign before interval 1
and 1 day would be added automatically.
select * from mytable where
mydate BETWEEN date_format(Now() - INTERVAL 1 DAY,'%e/%c/%Y - %H:%i:%s') AND date_format(Now(),'%e/%c/%Y - %H:%i:%s') ";
this one sorts for 1 day.
if you need week, month, 45, 52 or 665 days
change this
Interval 1 to Interval 45
number is important....
to add dates change minus sign before interval 1
and 1 day would be added automatically.
Last edited by fatihpiristine; Nov 2nd, 2007 at 10:57 am.
Do a favour, leave me alone
![]() |
Similar Threads
- calculate age (VB.NET)
- Oracle Help Needed (Oracle)
- Any help would be appreciated (MySQL)
- Difference between 2 dates by month (MS Access and FileMaker Pro)
- Sorting in date order (Visual Basic 4 / 5 / 6)
- How do I calculate ages (MS SQL)
- Access DB Help: Tables (Visual Basic 4 / 5 / 6)
- ASP Date Help - If Then Else (ASP)
- Querying within the results of a previous query? (MySQL)
Other Threads in the MySQL Forum
- Previous Thread: multiple search terms+fulltext search
- Next Thread: load data infile - fails to load my db2 del (ascii) file
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groklaw hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire law legal license licensing linux maintenance managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization





