I know that the Internet has enough information about the dates, but I have problems using what I saw.
I have calender management associated with a text box. He takes it in the form of 11/15/2010 (British). I use it to query datetime fields in a db SQL server in the format 11/15/2010 00:00:00.
After capturing the date by postback, I pass the values to my method, which tries to convert the text to a temporary format. When I request something between 01/01/2010 and 01/07/2010, I get a series of results. When I change this between 01/01/2010 and 30/10/2010, I get an error message. The error is invalid foreach (not yet caught the error). I assume this is due to my formats?
function getSupportTicketsbySubIssueAndDate($subissueid, $from, $to){
$subissueid = $this->ms_escape_string($subissueid);
$from = date("DD/MM/YY", strtotime($from));
$to = date("DD/MM/YY", strtotime($to));
$connection = new Connections();
$conn = $connection->connectToWarehouse();
$atid = $_SESSION['saveddata']['autotaskid'];
$tsql = "SELECT wh_task.task_id, wh_task.task_name, wh_task.task_description, wh_task.task_number, wh_task.reported_by_name, wh_task.create_time, wh_resource.first_name, wh_resource.last_name, wh_task_status.task_status_name ".
"FROM wh_task_status INNER JOIN (wh_task INNER JOIN wh_resource ON wh_task.assigned_resource_id = wh_resource.resource_id) ON wh_task_status.task_status_id = wh_task.task_status_id ".
"WHERE (account_id = $atid) AND (subissue_type_id = $subissueid) AND (((wh_task.create_time) Between '$from' And '$to'))".
"ORDER BY create_time DESC";
$ticket;
$stmt = sqlsrv_query( $conn, $tsql);
if( $stmt === false)
{
echo "Error in query preparation/execution.\n";
die( print_r( sqlsrv_errors(), true));
}
$x = 0;
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC))
{
$ticket[$x][0] = $row['task_name'];
$ticket[$x][1] = $row['task_description'];
$ticket[$x][2] = $row['task_number'];
$ticket[$x][3] = $row['reported_by_name'];
$ticket[$x][4] = $row['first_name'];
$ticket[$x][5] = $row['last_name'];
$ticket[$x][6] = $row['task_status_name'];
$ticket[$x][7] = $row['create_time'];
$ticket[$x][8] = $row['task_id'];
$x++;
}
return $ticket;
}
Any help is most appreciated!
Jonesi