Link to home
Start Free TrialLog in
Avatar of red_75116
red_75116Flag for United States of America

asked on

Query for timesheet application

I have a query pulling date records and i would like to make report showing a grid type results.  My original data pulls records based on a date, but I need all dates for the next 90 days.  My query is grouping by date and mostly on the weekends, there is no data and therefore those records don't exist.  I need a simple way to get at least 1 record for the next 90 days.  I have a CTE query, but cannot understand how to join this to my original dataset.

Is there any easier way to accomplish?

Here is a sample of the data

|Empid|  Name  | Date  |  Hours  |
|368     | Ann       | 3-17  |    4         |
|368     | Ann       | 3-19  |    5         |
|368     | Ann       | 3-20  |    7         |
|369    | Bob        | 3-17  |    4         |
ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of red_75116

ASKER

Thanks for the help
IMPORTANT CORRECTION:

CROSS APPLY (
    SELECT DATEADD(DAY, ct.number, CAST(GETDATE() AS date)) AS Date
) AS ca1


You're welcome :-),  Sorry about the code mix up -- I changed my approach while writing the code and didn't perfectly re-adjust the code.