Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to show last 10 days collection through query.

What I have tried:

select   CONVERT(DATE, transactionTimestamp) , sum(CAST (replace(amount, ',', '') AS INT)) from Transactions where agentCode=6 Group By  CONVERT(DATE, transactionTimestamp) 


and also try this query
select  cast(transactionTimestamp as date) < dateadd(day, -10, getdate())  , sum(amount) from Transactions where agentCode=3   group by cast(transactionTimestamp as date)
Posted
Updated 16-Apr-19 3:02am

1 solution

So you have to create correct where statement:

SQL
WHERE transactionTimestamp BETWEEN DATEADD(D, -10, GETDATE()) AND GETDATE()


For further details, please see:
DATEADD (Transact-SQL) - SQL Server | Microsoft Docs[^]
 
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