• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SQL] Search for available personnel

#1
Hi there!

I have a table with jobs in my app. 

Here it is with a from date and to date and of course the employee_id. 

I want to list everyone that is available between two dates. 

Whats the best practice for this?

Thanks.
Reply

#2
PHP Code:
SELECT *
FROM order_details
WHERE your_date 
>= CAST('2014-02-01' AS DATE)
AND 
your_date <= CAST('2014-02-28' AS DATE);


$query $this->db->where('yourDate >='$startDate)
 
                 ->where('yourDate <='$endDate)
 
                 ->get('yourTable'); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
@user4852

...or (https://www.codeigniter.com/userguide3/d...y-bindings )


$sql = "SELECT * FROM order_details Where your_date >= ? and your_date <= ?";
$this->db->query($sql, array('2014-02-01', '2014-02-28'));

or If you have to cast the strings as dates...

$sql = "SELECT * FROM order_details Where your_date >= CAST(? as DATE) and your_date <= CAST(? as DATE)";
$this->db->query($sql, array('2014-02-01', '2014-02-28'));
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.