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

(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?

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




Theme © iAndrew 2016 - Forum software by © MyBB