Jump to content

Selecting completed jobs between 2 dates


ckbis1

Recommended Posts

Hi

 

I need to create a pdf report of one of my tables in my database, creating the pdf was easy just used fpdf, but what i am struggling with now is trying to generate that report on data for the past 30 days (i am trying to make a monthly report), my snap shot of my code follows:

 

"

 

echo $date = date("Y-m-d") ;

echo $date2 = "select(DATESUB($date, INTERVAL 31 DAY)";

 

 

 

$pdf->Table("select j_num, building,room, description,reason, type, contractors, staff, start_time, end_time, cost, note FROM job WHERE completed = 'yes' BETWEEN $date and $date2 ",$prop);

$pdf->Output();

?>

 

"

 

the first echo gives me this - "2012-05-09" which is right i need the system date

the second echo gives me this - "select(DATESUB(2012-05-09, INTERVAL 31 DAY)" which is wrong it should be minusing 30days from the system date

 

THIS IS THE ENTIRE ERROR THAT I GET IN MY BROWSER:

 

2012-05-09select(DATESUB(2012-05-09, INTERVAL 31 DAY)Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select(DATESUB(2012-05-09, INTERVAL 31 DAY)' at line 1

Query: select j_num, building,room, description,reason, type, contractors, staff, start_time, end_time, cost, note FROM job WHERE completed = 'yes' BETWEEN 2012-05-09 and select(DATESUB(2012-05-09, INTERVAL 31 DAY)

 

 

is there something wrong with my syntax? well i guess its kinda obvious there is, but what and any suggestions on how to fix it

 

 

Thanx

Chris

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...