복붙노트

[SQL] 가져 오기 데이터는 두 날짜 사이에 게시

SQL

가져 오기 데이터는 두 날짜 사이에 게시

어떻게 CodeIgniter의의 액티브를 사용하여 두 날짜 사이의 기록을 조회하여 데이터베이스에서 데이터를 검색 할 수 있습니다?

해결법

  1. ==============================

    1.이 모습은 당신이 필요로하는 것을 좋아한다 :

    이 모습은 당신이 필요로하는 것을 좋아한다 :

    $this->db->where('order_date >=', $first_date);
    $this->db->where('order_date <=', $second_date);
    return $this->db->get('orders');
    
  2. ==============================

    2.이 시도:

    이 시도:

    $this->db->where('sell_date BETWEEN "'. date('Y-m-d', strtotime($start_date)). '" and "'. date('Y-m-d', strtotime($end_date)).'"');
    

    이 의지 작업을 희망

  3. ==============================

    3.이것은 나를 위해 큰 일

    이것은 나를 위해 큰 일

    $this->db->where('sell_date BETWEEN "'. date('Y-m-d', strtotime($start_date)). '" and "'. date('Y-m-d', strtotime($end_date)).'"');
    
  4. ==============================

    4.이것은 나를 위해 일한 :

    이것은 나를 위해 일한 :

    $this->db->where('RecordDate >=', '2018-08-17 00:00:00');
    $this->db->where('RecordDate <=', '2018-10-04 05:32:56');
    
  5. ==============================

    5.당신은 SQL 날짜를 비교하려면이 시도 할 수 있습니다 :

    당신은 SQL 날짜를 비교하려면이 시도 할 수 있습니다 :

    $this->db->select();
    $this->db->from('table_name');
    $this->db->where(' date_columnname >= date("'.$from.'")');
    $this->db->where( 'date_columnname <= date("'.$to.'")');
    

    그것은 (PHP와 MySQL) 날 위해 일했습니다.

  6. ==============================

    6.당신이 도움이 월 .... 세 개의 테이블의 참여로

    당신이 도움이 월 .... 세 개의 테이블의 참여로

    public function get_details_beetween_dates()
        {
            $from = $this->input->post('fromdate');
            $to = $this->input->post('todate');
    
            $this->db->select('users.first_name, users.last_name, users.email, groups.name as designation, dailyinfo.amount as Total_Fine, dailyinfo.date as Date_of_Fine, dailyinfo.desc as Description')
                        ->from('users')
                        ->where('dailyinfo.date >= ',$from)
                        ->where('dailyinfo.date <= ',$to)
                        ->join('users_groups','users.id = users_groups.user_id')
                        ->join('dailyinfo','users.id = dailyinfo.userid')
                        ->join('groups','groups.id = users_groups.group_id');
    
            /*
            $this->db->select('date, amount, desc')
                     ->from('dailyinfo')
                     ->where('dailyinfo.date >= ',$from)
                     ->where('dailyinfo.date <= ',$to);
            */
    
            $q = $this->db->get();
    
            $array['userDetails'] = $q->result();
            return $array;
        }
    
  7. ==============================

    7.

    $query = $this->db
                  ->get_where('orders',array('order_date <='=>$first_date,'order_date >='=>$second_date))
                  ->result_array();
    
  8. ==============================

    8.당신은 CodeIgniter의 쿼리 도우미에 키워드 BETWEEN 사용하여 강제로합니다. 이 코드 등의 탈출 거짓없이 어디에 사용할 수 있습니다. CI 버전 3.1.5에서 잘 작동합니다. 의 도움 누군가를 바랍니다.

    당신은 CodeIgniter의 쿼리 도우미에 키워드 BETWEEN 사용하여 강제로합니다. 이 코드 등의 탈출 거짓없이 어디에 사용할 수 있습니다. CI 버전 3.1.5에서 잘 작동합니다. 의 도움 누군가를 바랍니다.

    if(!empty($tglmin) && !empty($tglmax)){
            $this->db->group_start();
            $this->db->where('DATE(create_date) BETWEEN "'.$tglmin.'" AND "'.$tglmax.'"', '',false);
            $this->db->group_end();
        }
    
  9. ==============================

    9.그냥 단순히 BETWEEN 쓰기 '{$의 startDate}'및 '{$ endDate가}'어디 상태 같이

    그냥 단순히 BETWEEN 쓰기 '{$의 startDate}'및 '{$ endDate가}'어디 상태 같이

    ->where("date BETWEEN '{$startDate}' AND '{$endDate}'")
    
    
  10. ==============================

    10.보관 된 타임 스탬프를 최신 상태 경우 다음이 기록을 얻을 수있는 쉬운 방법입니다

    보관 된 타임 스탬프를 최신 상태 경우 다음이 기록을 얻을 수있는 쉬운 방법입니다

    $this->db->where('DATE(RecordDate) >=', date('Y-m-d',strtotime($startDate)));
    $this->db->where('DATE(RecordDate) <=', date('Y-m-d',strtotime($endDate)));
    
  11. from https://stackoverflow.com/questions/4875668/getting-data-posted-in-between-two-dates by cc-by-sa and MIT license