SELECT DatesTable.EmployeeId, DatesTable.StartDate, DatesTable.EndDate FROM ( SELECT ( NEXT_DAY( SYSDATE-7, TO_CHAR( TO_DATE( '2/6/2014','dd/mm/yyyy' ), 'DY' ) ) + 7 ) - ( monthincrement * 7 ) AS StartDate, ( NEXT_DAY( SYSDATE-7, TO_CHAR( TO_DATE( '2/6/2014','dd/mm/yyyy' ), 'DY' ) ) + 13 ) - ( monthincrement * 7 ) AS EndDate, @EmployeeId AS EmployeeId FROM dual, ( SELECT LEVEL AS monthincrement FROM dual CONNECT BY LEVEL <= ( TRUNC( SYSDATE ) - NEXT_DAY( TO_DATE( @FirstDayUserTimesheet , 'dd/mm/yyyy' ) - 7, TO_CHAR( TO_DATE( '2/6/2014','dd/mm/yyyy' ), 'DY' ) ) ) / 7 ) ) DatesTable WHERE 1=@IndHasEmployeeSelected AND NOT EXISTS ( SELECT 1 FROM {Timesheet} WHERE 1=1 AND TRUNC( {Timesheet}.[StartDate] ) = TRUNC( DatesTable.StartDate ) AND TRUNC( {Timesheet}.[EndDate] ) = TRUNC( DatesTable.EndDate ) AND {Timesheet}.[EmployeeId] = DatesTable.EmployeeId )
"From: " + Day(TableRecords1.List.Current.structSelectPeriod.StartDate) + "/" + GetShortMonth(Month(TableRecords1.List.Current.structSelectPeriod.StartDate)) + "/" + Year(TableRecords1.List.Current.structSelectPeriod.StartDate) + " - To: " + Day(TableRecords1.List.Current.structSelectPeriod.EndDate) + "/" + GetShortMonth(Month(TableRecords1.List.Current.structSelectPeriod.EndDate)) + "/" + Year(TableRecords1.List.Current.structSelectPeriod.EndDate)