Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

How to get the lastweek datafrom Database table

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

How to get the lastweek datafrom Database table

Postby stephenrodrics » Wed May 22, 2013 5:57 am

I want to get the details of employees who have not submitted there timesheet for last week.

my query is

Select EMPID from employee table where manager = 'john' and lastweek not between '2013-05-12' and '2013-05-19'

But this fetch me current week list also as it falls in NOT criteria, can anyone help me to get the records which fall in last week category.


I update employee table wheever any save operation happens and lastweek date is updated with current date.

any clue how to maintain the weekly status of submittion in database
stephenrodrics
New php-forum User
New php-forum User
 
Posts: 57
Joined: Thu Mar 14, 2013 6:10 am

Re: How to get the lastweek datafrom Database table

Postby johnj » Wed May 22, 2013 9:48 pm

please post the employee table structure (fields).
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: How to get the lastweek datafrom Database table

Postby stephenrodrics » Thu May 23, 2013 1:26 am

employeedb table

EmployeeID int(255)
employeename varchar(50)
ReportingTo varchar(500)
lastweek date


Data

EmployeeID EmployeeName ReportingTo lastweek
2022 Sam John 2013-05-22



weekly table Structure is

Employeename varchar(50)
Empid int(20)
Subweek date
ReportingTo varchar(35)
Submitstat varchar(30)

Employeename EmpId SubWeek ReportingTo Submitstat

Sam 2022 2013-05-10 John Approved
Sam 2022 2013-05-22 John Submitted


if you see EmployeeName sam has not submitted his timesheet for 2013-05-17 that is in between 10-22 May, I am trying to get that info, search those employees who have not submitted there timesheet for a given week.

I update the employeedb table with last submittion date as in above latest timesheet submittion date is 2013-05-22 so everytime when a employee submits this date gets changed in lastweek field to latest one.
stephenrodrics
New php-forum User
New php-forum User
 
Posts: 57
Joined: Thu Mar 14, 2013 6:10 am

Re: How to get the lastweek datafrom Database table

Postby johnj » Sat May 25, 2013 12:59 am

I have not tested this sql but you can try something like this:
Code: Select all
select employeename from employeedb where employeename NOT IN (select employeename from weekly_table where subweek between '2013-05-12' and '2013-05-18')
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.