red_75116
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 |
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
ASKER