Forum Moderators: open

Message Too Old, No Replies

mysql query - substring

         

bilenkyj

10:41 am on Oct 20, 2008 (gmt 0)

10+ Year Member



Hi Guys i have no idea how to run this query and return the values im looking for

i have a db table with rows i need to perform calcuations on.
im looking to sum up the totals for 2 columns based on some parameters

$sumtotals =mysql_query("SELECT SUM(est_hours), SUM(act_hours) FROM timeline WHERE week_no="$counter" AND week_com_date="SUBSTR($theyear)"");

the issue i think is this

week_com_date="SUBSTR($theyear)"

in my db i have a date field yyyy-mm-dd but all i need to check is that the year is correct - i need to look at the date field and if 2008 is present then select the row values est_hours and act_hours (if week number is correct as well of course)

im not sure how to do that- can anyone help out at all?

bilenkyj

12:55 pm on Oct 20, 2008 (gmt 0)

10+ Year Member



i used this in the end -

WHERE YEAR(week_com_date) = '$theyear'