无法使用php mysql从数据库中获取和到达日期值

时间:2016-04-06 10:04:07

标签: php mysql

我正在尝试使用todate,fromdate,projectid项目名称,活动名称,持续时间,员工姓名,但我无法在此处获取我的代码和方案

select ohrm_project.project_id as ohrmprojectid,ohrm_project.customer_id,ohrm_project.name as ohrm_projectname,ohrm_timesheet.timesheet_id as ohrmtimesheet_id, ohrm_timesheet.employee_id as ohrmtimesheetemployeeid,ohrm_timesheet_item.*, ohrm_project_activity.activity_id as ohrmprojectactivityid, ohrm_project_activity.project_id as ohrmprojectactivityprojectid, ohrm_project_activity.name as activityname,hs_hr_employee.* from ohrm_project,ohrm_timesheet,ohrm_timesheet_item,ohrm_project_activity,hs_hr_employee where ohrm_timesheet_item.project_id=2 and ohrm_timesheet_item.activity_id=ohrm_project_activity.activity_id and ohrm_timesheet_item.employee_id=hs_hr_employee.emp_number and ohrm_timesheet_item.employee_id=hs_hr_employee.emp_number and ohrm_timesheet_item.date between 2016-03-31 and 2016-04-04

click here to see image

click here to see image

2 个答案:

答案 0 :(得分:1)

使用此:

SELECT ohrm_project.project_id AS ohrmprojectid,
   ohrm_project.customer_id,
   ohrm_project.name AS ohrm_projectname,
   ohrm_timesheet.timesheet_id AS ohrmtimesheet_id,
   ohrm_timesheet.employee_id AS ohrmtimesheetemployeeid,
   ohrm_timesheet_item.*,
   ohrm_project_activity.activity_id AS ohrmprojectactivityid,
   ohrm_project_activity.project_id AS ohrmprojectactivityprojectid,
   ohrm_project_activity.name AS activityname,
   hs_hr_employee.*
FROM ohrm_project,
     ohrm_timesheet,
     ohrm_timesheet_item,
     ohrm_project_activity,
     hs_hr_employee
WHERE ohrm_timesheet_item.project_id=2
  AND ohrm_timesheet_item.activity_id=ohrm_project_activity.activity_id
  AND ohrm_timesheet_item.employee_id=hs_hr_employee.emp_number
  AND ohrm_timesheet_item.employee_id=hs_hr_employee.emp_number
  AND ohrm_timesheet_item.date BETWEEN '2016-03-31' AND '2016-04-04'

答案 1 :(得分:0)

日期将被视为string s。用quote包裹它们。

ohrm_timesheet_item.date between '2016-03-31' and '2016-04-04'