Welcome Guest, Not a member yet? Register   Sign In
[SQL] Search for available personnel

(This post was last modified: 11-26-2018, 05:06 AM by ciadmin.)

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?


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

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

Joined CodeIgniter Community 2009.  ( Skype: insitfx )


...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'));

Theme © iAndrew 2016 - Forum software by © MyBB