Date format in "where" clause

4 posts by 2 authors in: Forums > CMS Builder
Last Post: March 2, 2013   (RSS)

By nmsinc - March 1, 2013

I have an issue with a date clause in a "where" statement no returning values:

----------------------------------------------------------------------------------------------------------

// get payroll date details
  $dates1 = mysql_get('payroll_dates', 1);

  $start = date("Y-m-d", strtotime($dates1['start_date']));
  $end = date("Y-m-d", strtotime($dates1['end_date']));

elseif (!$CURRENT_USER['disabled']) {
    $where = "employee_name = '".intval($CURRENT_USER['employee_number'])."' AND hours_worked > 0 AND date_hours_worked <= $end OR employee_name = '".intval($CURRENT_USER['employee_number'])."' AND hours_worked > 0 AND date_hours_worked >= $start ";

Any suggestions?

Thanks - nmsinc
 

nmsinc

By nmsinc - March 1, 2013

Hi Greg,

I'm still getting all listings using you suggestion. Any other suggestions?

nmsinc

By nmsinc - March 2, 2013

I found my error - see correction below:

$where = ("employee_name = '".intval($CURRENT_USER['employee_number'])."' AND date_hours_worked BETWEEN '$start' AND '$end' ");

Works just fine now!

nmsinc