0

I want to get the week off from a table. The table having a field tblweekoff the

fldid   flddept     fldemployee         fldintime   fldouttime  fldlateafter    fldearlybefore  fldweekoff  fldshiftname    fldassigndate   fldfromdate fldtodate   fldrefid
1       Corporate   00625267-Karthick S 09:30 am    06:15 pm    09:30 am        06:15 pm         Sat,Sun,   COR-General Shift 07-25-2012    07-01-2012  07-31-2012

I want to get the report like this.

fldemployee           flddate       fldweekoff 
00625267-Karthick S   07-25-2012    
00625267-Karthick S   07-27-2012    
00625267-Karthick S   07-28-2012    weekoff
00625267-Karthick S   07-29-2012    weekoff
00625267-Karthick S   07-30-2012    
00625267-Karthick S   07-31-2012    
00625267-Karthick S   08-01-2012    weekoff
00625267-Karthick S   08-02-2012    weekoff
00625267-Karthick S   08-03-2012    
00625267-Karthick S   08-04-2012   
......

I want to get the report from 07-25-2012 to 08-10-2012 means the above result display like that..

Please help me to do this..

romi
  • 611
  • 1
  • 9
  • 16

3 Answers3

0

Isn't just like this?

SELECT fldemployee, flddate, fldweekoff FROM yourtablename WHERE fldweekoff = `weekoff` AND flddate > `07-25-2012` AND flddate < `08-10-2012`;

There might be a minor error in this query, but it's should be close to what you want.

marcinsdance
  • 634
  • 7
  • 17
0

You will first want to create a calendar table.

See Mysql: Select all data between two dates

From there you can join the results from the calendar table to the employees.

Community
  • 1
  • 1
Matt Tew
  • 1,581
  • 1
  • 9
  • 15
0

Im assuming you use mySql workbench?

use this command

SELECT * FROM `a_database`.`a_table` where `flddate` >= '07-25-2012' and `flddate` <= '08-10-2012' and `fldweekoff` = 'weekoff';
Francois
  • 10,465
  • 4
  • 53
  • 64