Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want last 5 dates of records from today date.
In that table records employees shift wise working list.for example one person working one day and next day he is not working and next day he is working.it will suitable for each and every employees. i need the result set who r all not working for last 5 days from today date.


SQL SERVER
Posted
Comments
OriginalGriff 28-Nov-14 1:46am    
And?
What have you tried?
Where are you stuck?
We can't do much to help without your table(s) and some sample data.
Use the "Improve question" widget to edit your question and provide better information.
Rajesh waran 28-Nov-14 1:47am    
can you provide your table design with sample entries?

1 solution

Hi,
Check this hope this will help you.

SQL
    -- this sample query to display today and 5 days before from today
 select getdate(),DATEADD(dd,-5,getdate())     
                                                              
-- This sample query will return result between 5 days
SELECT * FROM YourTable_Name
WHERE
YOURDateColumn BETWEEN  DATEADD(dd,-5,getdate()) and getdate()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900