sql server - Hi,How to get last 5 days from current date -
how last 5 days current date below sqlquery please me in advance.
select b.emp_code, b.emp_name,b.general_shift g, b.first_shift f, b.second_shift s, b.third_shift t,b.dt ( select a.* ( select emp.emp_code,emp.emp_name, et.general_shift, et.first_shift, et.second_shift, et.third_shift, --et.day, et.month,et.year, convert(date,'20'+convert(varchar(10),et.year,120)+'-'+ convert(varchar(10),et.month,120)+'-'+ convert(varchar(10),et.day,120)) dt emp_fponm_emp_time_sheet et, emp_fponm_employee_information emp et.emp_id = emp.emp_code , emp.dept_id = 44 , emp.status='present' , emp.emp_code = 'onm_001903' , emp.site_id=20 ) dt between getdate()-5 , getdate() ) b
dateadd
fix problem :
where dt between dateadd(day, -5, getdate()) , getdate()
Comments
Post a Comment