Hi everyone, im after a bit of help on the simplest of PHP/MySQL problems. Scenario: I am creating a get_week_number() function which established the current date and stores the value in the $_SESSION['current_date'] variable, I then initiate a query which compares this value to the start_date and end_date fields in a table named 'week' to establish the current week number. <?php session_start(); require_once ('./includes/db_connect.php'); $current_date = date("Y-m-d"); $_SESSION['current_date'] = $current_date; if (isset($_SESSION['current_date'])){ $query = "SELECT week.week_id FROM week WHERE '{$_SESSION['current_date']}' >= week.start_date AND < week.end_date "; $result = mysql_query($query); // Return a record, if applicable. $row = mysql_fetch_array ($result, MYSQL_NUM); if ($row) { $_SESSION['week_number'] = $row[0]; echo ("The week_number is " .$_SESSION['week_number']); } else{ echo ("The Week is $current_date"); } } ?> Code (markup): Problem : There are no errors on the page, however according to the table the week number should be 28 yet the week number that the query retrieves is always week number 26. Im not sure what to do?? Any help would be highly appreciated, and feel free to give me a clip round the ear, for missing something that I can imagine is going to be easy to solve.
Are you trying to get the week number of a certain date? Try this : echo date("W",timestamp); Code (markup): If not, tell me.