Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
CSS
name   amount date
 xxx     1000  2014-04-20 12:53:23.983
 yyy     1500   2014-04-25 12:53:23.983

 my output like this:

 name  amount  date
 xxx     1000  2014-04-20 12:53:23.983


 my query:

 alter proc K_VM_GetTaxdetails
 as
 begin

 select name,amount,date from K_VM_TaxDetails
 where  DATEADD(day, -15, GETDATE())=date
 end

i have treid like this but iam not getting required output.
if,In my table date=2014-04-20 12:53:23.983 so
i want to display before 15 days from that date.
how can i write in where condition, its urgent please help me out....
Posted

One way is to use BETWEEN to define the date range. For example:
SQL
SELECT td.Name, td.Amount, td.Date 
FROM K_VM_TaxDetails td
WHERE td.Date BETWEEN DATEADD(day, -15, GETDATE()) AND GETDATE()

For more information, see:
 
Share this answer
 
you can get the last 15 days records;
SQL
select *from K_VM_TaxDetails where paid_date>=DATEADD(day,-15,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